Concepts of “JavaScript”

Md. Nur-E-Alom Siddiky
4 min readMay 6, 2021

--

1.Error Handling

Errors is a part of code so it appears every times in code. So all the time we need to handle errors. there are some keywords for error handling in JavaScript.

try{}
catch{}
through{}
finally{}

  1. try statements let you test a block of codes for error.
  2. catch statements let you handle those error.
  3. the through statements let you create customer errors.
  4. and the finally statement let you execute after trying catch regardless of the result.
try {
// code…
}
catch (error) {
// error handling
}

first code try{…} is execute if code no error catch ignore and if code error try ignore and catch in and showing error.

2. Functions in Loops

Just as a loop is an embodiment of a piece of code we wish to have repeated, a function is an embodiment of a piece of code that we can run anytime just by calling it into action. A given loop construct, for instance could only be run once in its present location in the source code.

Loop statements usually have four components: initialization (usually of a loop control variable), continuation test on whether to do another iteration, an update step, and a loop body.

The behavior of var made creating functions inside of loops problem because the loop variables are accessible from outside the scope of the loop.

var fun = [];for (var i = 0; i < 10; i++) {
fun.push(function() { console.log(i); });
}
funcs.forEach(function(func) {
func(); outputs the number “10” ten times
});

3.Spread Operator.

spread operator array element and one more element adding create a new array easily also spread operator object element and another element adding e all element create a new object. and change original array or object easily.

Example: Array

const arr1 = [1,2,3,4];
const arr2 = [5,6,7,8];
const newArr = […arr1, …arr2];

Example: OBJECT.

let p1 = {name: “Siddiky”, age: 25}let p2 = {country: “Bangladesh”, occupation: “Developer”}let p = {…p1, …p2}console.log(p);output={name: ‘Siddiky’, age: 25, country: ‘Bangladesh’, occupation: ‘Developer’}

4.Caching

Caching is a technique that stores a copy of a given resource and serves it back when requested. When a web catch has a requested resource in its store, it intercepts the request and returns its copy instead of re-downloading from the originating server.

Client side Caching - Caching is the process of storing copies of files in a cache, or temporary storage location, so that they can be accessed more quickly. Technically, a cache is any temporary storage location for copies of files or data, but the term is often used in reference to Internet technologies. Web browsers cache HTML files, JavaScript, and images in order to load websites more quickly, while DNS servers cache DNS records for faster lookups and CDN servers cache content to reduce latency.

Server side Caching - Web cache, server cache (or HTTP cache) is an information technology for the temporary storage (caching) of web documents, such as HTML pages and images, to reduce server lag. A web cache system stores copies of documents passing through it; subsequent requests may be satisfied from the cache if certain conditions are met. A web cache system can refer either to an appliance, or to a computer program.

5.Cross browser testing

Cross browser testing is the practice of making sure that the web sites and web apps you create work across an acceptable number of web browsers. its like we may use different browser like Chrome, Mozilla, Opera, Microsoft Edge any many more.

There are many different reasons why cross browser issues occur, and note that here we are talking about issues where things behave different across different browsers / devices / browsing preferences. Before you even get to cross browser issues, you should have already fixed out bugs in your code (see Debugging HTML, Debugging CSS, and What went wrong? Troubleshooting JavaScript from previous topics to refresh your memory if needed).

Cross browser testing involves comparing and analyzing the behavior of your website in different browser environments. It helps ensure that your website delivers an optimal user experience, independent of the browser used to access it.

--

--

Md. Nur-E-Alom Siddiky

A progressive JavaScript Developer and part time writer.