10 Advance thing you should know as a js Developer

Mainul Islam Faruqi
3 min readNov 3, 2020

1.Hoisting: Hoisting suggests that variable and function declaration are moved to the top of your code before execution.

The above code snippet is we call the function before we write the function and the code still works.

only declarations of the variable are hoisted, not initialization.

Here just initialized the variable not declared and throws ReferenceError exeption

2. Default function parameters: When we declare the function, then we can provide the initial value of parameters. It is also a named parameter.

If we pass the value of named parameters, the value of the default parameters will change.

3. Block-level Declaration: The block is delimited by a pair of curly brackets. Only variable declaration with var can be updated in the block and outside of the block. And let declaration can not be updated in the block but can be updated outside of the block.

4. Block-level function: In strict mode, function in the block are now scooped. That means we can not access the block level function outside the block.

We can't access the block level function outside the block.

5.Spread Operator: Spread operator (…) expanded or copy arguments, (for function calls) elements, (for array literals) key-value pair (for object literals). And put it in a place where use it.

Spread operator copy or expanded elements from the languages array and put it in a place.

Thus, we can expand elements for Array, arg for Function calls, and key value-pair for object.

6. Rest parameters: When declaring a function, we can use rest parameter with the prefix () as a last parameter. That means all the remaining arguments to be placed within an array. when we call the function and pass the arguments that are no declared as a parameter. These parameters will pass in the rest parameters.

we declared a, b and …manyMoreArgs (rest parameters). That means when we call the function and pass more than two parameters, then all remaining parameters will pass with rest parameters and returns an Array.

7. Arrow Function:

8. Types of Values: After almost 25 years of studying JavaScript, the scientists have only discovered nine types of value.

  1. Undefined: used for unintentionally missing values.
  2. Null: used for intentionally missing values.
  3. Booleans(true or false): used for logical operations.
  4. Numbers: used for math calculation.
  5. Strings: used for text.
  6. symbols(uncommon): used for implementation details.
  7. BigInts(uncommon and new): used for math on Big numbers.
  8. Objects({} and others): used to group related data and code.
  9. Functions: Used to refer to code.

9. comments: comments are very important to describe how and why the code works

// used for single line comments.

/* …….. */ used for multiline comments.

10. Coding Style:

  1. curly Braces:
always when starting curly braces, then close the braces to the next line.

2. line length: No one likes to read a long horizontal line of code. So it’s best practice to split them.

3. Indents: Horizontal indents 2 or 4 spaces and vertical indents empty lines for splitting code into logical blocks.

4. Semicolons: A semicolon should be present after each statement.

5. Nesting Levels: Try to avoid nesting code too many levels deep.

--

--

Mainul Islam Faruqi

I am a full-stack web developer. Programming makes our life better. Writing code is my hobby. I am very passionate to write code.