JavaScript Error Handling Block Binding ……

Shahibur Rahman
2 min readMay 7, 2021

try-Catch:

When wring code there are different error may occurs. To handle the error programmer use try-catch method.

How it works:
Syntax: try{
Some Code
}
catch(err){
Some Code
}

first try block is run. If there is no error then catch part is ignored. if an error found form try part then try part is stopped and catch part executes.

try-catch-finally:

finally block run in all cases.

syntax:
try{some code} //runs while no error occurs
catch{some code} //runs while error found on try block
finally{some code}//runs always

Block Binding:

Declaration of a JavaScript variables is different. Blocks are created when declare a function.
var type variables: Using var in JavaScript, it declares the variable globally and access this variable outside of the block also.
let type variables:Using let is exactly the same use as var. The work is similar but the scope of let is limited to the block. let type variables can’t access from outside of the block.
const type variables:Using const is considered as constants, so this values cannot be changed once set.

Arrow Function:

arrow function is a alternative of a traditional function.

syntax:
no parameter example: ()=> expression
one parameter example: param => expression
multiple parameter example: (param1,paramN)=>expression

The Spread Operator:

The spread operator indicates as …(three dots). It is used to apply adding items to arrays/object quickly.
example: function sum(a, b, c) {
return a+ b+ c;
}
const num = [1, 2, 3];
console.log(sum(…num)); // expected output: 6

Cross Browser Test:

Cross browser testing is the process to sure that the web sites work on different web browsers. Some features of this testing:
1. Base Functionality.
2. Design.
3. Accessibility.
4. Responsiveness.

Coding Style:

Coding style is the art of a programmer. Coding should be meaning full. There are some things professional programmer should follow:

  1. variable declaration is meaningful.
  2. Line Indentation should not be more then 3 or more tabs.
  3. After each statement semicolon is used.
  4. For declaration of function(s), code first then function.
  5. Good comments should be used.

Functions with Default Parameter Values:

If a parameter of a function does not assign the default value is undefined. But in ES6 we set a default parameter with value. If parameter was missing then the default value is set against those parameter.

--

--