10 Fundamentals, JavaScript Developer’s should know

Ridwanul Alam
3 min readMay 6, 2021

1. Try …Catch:

During javascript code execution there are errors that might occur results blocked the whole execution. Sometimes programmers face a great problem dealing with these hidden errors.

Errors can be occurred due to giving in wrong input, applying the wrong syntax, and other unforeseeable things.

We can easily handle these issues by applying the try-catch method.

try{
// code start to execute the whole code, unless it'll find any error
}
catch{
//if any error found in try , then catch is began to execute and execution doesnt blocked due to error. It gives the programmer the error message which helps the programmers to debug
}

2. Var Declarations and Hoisting:

If we declare a variable with “var” they are hoisted to the top of the function or global scope if it is declared outside of a function.

3. Block-Level Declarations

If we declare a variable using let or const’ that are not hoisted to the top of the enclosing block which limits the variable’s scope. But if we want the variables are available to the entire block then we can declare the variable using let or const first in the block.

4. Default Parameters Value in ES6

It allows you to set default values for your function parameters if no value is passed or if undefined is passed.

const add =(a=3, b=5) => {
return a + b;
}

add(4,2) // 6
add(4) // 9
add() // 8

5. Spread Operator

Spread operator “spreads” the values in arrays across zero or more arguments or elements. The Spread syntax is simply three dots (...)

const pet = ['cat', 'dog', 'parrot'];

const wild = [...pet, 'wolf', 'lion'];
console.log(wild) // [ 'cat', 'dog', 'parrot', 'wolf', 'lion' ]

Spread Operator can also be applied for Object,

const pet = { animal-1: 'cat', animal-2: 'dog', animal-3: 'parrot'};
const wolf = {...pet, animal-4: 'wolf', animal-5: 'lion'};
console.log(wolf);
// {
animal1: 'cat',
animal2: 'dog',
animal3: 'parrot',
animal4: 'wolf',
animal5: 'lion'
}

6. Block level function

In ES6, a function is considered as a block-level function and can be accessed and called within the same block in which it was defined. Block-level functions are hoisted to the top of the block in which they are defined.

7. Arrow Function:

In ES6 we may declare a function alternative to a traditional function expression. Arrow functions are more concise and easier to read.

For example,

const add = (a, b) => a + b;

If we declare the arrow function in a traditional way

function add(a,b){
return a+b
}

Using arrow functions with promises/callbacks is reduces the confusion surrounding the thiskeyword.

8. Cross Browser Testing

It is a method by which ensures the quality of your website on different screens. As a web developer, it is important to make sure that your projects work properly for all your users, for all browsers & devices.

9. Comments:

Comments are used to explain JavaScript code, and to make it more readable. In Javascript comments can be single-line: starting with // and multiline: /* ... */. Good comments allow you to maintain the code well and use it more effectively.

Things should be remembered before comments:

It is not necessary to tell “how code works” and “what it does”.

--

--

Ridwanul Alam

A Frontend Web Developer. Devoted to solving new problems and developing interactive web application