1.JavaScript Try…Catch

In JavaScript, the try statement allows you to add a block of code that will be tested for errors when it is executed. If an error does occur in the try block, the corresponding catch statement will be executed. You can think of the try and catch statements as a pair.

2. JavaScript Comments

JavaScript comments can be used to explain JavaScript code, and to make it more readable. We normally use them to describe how and why the code works.

Single Line Comments :

Single line comments start with //.

any text between // and the end of the line will be ignored. Follow the example below :

// Changing heading:

document.getElementById(“myHeading”).innerHTML = “My First Page”;

// Changing paragraph:

document.getElementById(“myParagraph”).innerHTML = “My First Paragraph”;

Multi Line Comments :

Multi-line comments start with /* and end with */.

Any text between /* and */ will be ignores. Follow the example below :

/*

document.getElementById(“myHeading”).innerHTML = “My First Page”;

document.getElementById(“myParagraph”).innerHTML = “My First Paragraph”;

*/

3. Balancing Client and Server

Balancing is a crucial part for the success of a web application.Currently there are two major methods of balancing. They are client-side balancing and server side balancing. These methods have been used for different requirements. In this article, we will be discussing which balancing method to use for a particular application.

Cost: Cost is a major factor for developing an application. If you are using a server side load balancer then you need to dedicate a separate server for that. So it will cost you some money. But if you are using a client side load balancer then you can keep the load balancer with your client code. Therefore no need to spend additional money.

4. Var Declarations and Hosting

Variable declarations using var are treated as if they are at the top of the function (or global scope, if declared outside of a function) regardless of where the actual declaration occurs; this is called hoisting. Consider the examples below:

function simpleExample(condition) {

var value;

if (condition) {

value = “blue”;

return value;

} else {

return null;

}

}

The declaration of value is hoisted to the top. The variable value is actually still accessible from within the else clause. If accessed from within the else clause, the variable value will be undefined because it hasn’t been initialized, it’s initialized only in If clause.

5. Block Binding in Loops

This is a area where developers most want block level scoping of variables is within for loops, where the throwaway counter variable is meant to be used only inside the loop. For this we have to use let not var, cause var is being hoisted. Follow the two examples below:

for (var i = 0; i < 10; i++) {

process(items[i]);

}

// i is still accessible here

console.log(i); // 10

The variable i is still accessible after the loop is completed because the var declaration gets hoisted. Using let instead, as in the following code to ignore this problem:

for (let i = 0; i < 10; i++) {

process(items[i]);

}

// i is not accessible here — throws an error

console.log(i);

In this example, the variable i only exists within the for loop.

6. Global Block Bindings

Another way in which let and const are different from var. When var is used in the global scope, which is a property on the global object (window in browsers). That means you can overwrite an existing global using var, such as:

// in a browser

7. Default function parameters

In JavaScript, a parameter has a default value of undefined. It means that if you don’t pass the arguments into the function, its parameters will have the default values of undefined. Follow the example below:

8. JavaScript Spread Operator

Spread operator allows an iterable to expand in places where 0+ arguments or elements are expected. It is mostly used in the variable array where there are more than 1 values expected. Follow the example below:

9. JavaScript Arrow Function

Arrow functions were introduced in ES6.

Arrow functions allow us to write shorter functions. Follow the example below:

10. Cross Browser Testing

Cross Browser testing is a type of non-functional testing. It is the practice of making sure that the web sites and web apps I create work across an acceptable number of web browsers. As a web developer, it is my responsibility to make sure that not only do my projects work, but they work for all my users, no matter what browser, device, or additional assistive tools they are using. I need to think to about :

Cross browser testing is important for sure that my created website is working on every device and browser.