Few !important things in JavaScript

JavaScript Expression
In JavaScript, expression is any valid piece of code that can generate value (like numeric, string, bool etc.)
According to MDN, there are different types of JavaScript expression. They are : a) Arithmetic b)String c)Logical d)Primary e)Left-hand-side

few examples of expressions in JavaScript

JavaScript Objects
JavaScript object is one kind of data types in JavaScript. It can construct with various collection of variables, function or objects.

JavaScript Object example
JavaScript Object example
example of JavaScript object data type

In a simplified definition, we can say that when a function is declared before defining it the definition is uplifted(behind the scene) and the code is also work.

Hoisting example

Block Binding in Loops
In JavaScript, block level scoping is not default, so when we use “var i =0” in a loop for counter, outside the loop, this “i” is also accessible with previous state count value.

example of block binding in JavaScript before block level scope

But, to solve this problem, block binding scope came. We can use const or let to solve this problem.

Block Scope
It is an area where there is nothing to do outside with inside, suppose, we defined a variable with value 3. If we print that variable outside the scope, it will show undefined.

Block scope example

Arrow Function
Besides traditional function definition, ES6 has arrow function different syntax than traditional function syntax. But it has few limitation. It can not be used in all kind of situation we need.

Example of Arrow Function

Spread Operator
Sometimes we need to assign with more data in another object or array. In that case, we have to iterate all element of array. So, spread operator is a solution for not iterating all and assign all data into a new one.

use of spread operator

“try … catch”
No matter who we are, we all are never be perfect. We may mistake in some case. So as in programming, we may create a situation where the code will end up in an infinite loop which will crush the system. To avoid this we use try … catch syntax.

try … catch structure

Function with default parameters
When we pass parameters to function, sometimes, few parameters will be missing for not availability. In this kind of situation, we may need a default value for this problem. So default parameters value might be helpful in this scenario.

Default parameters value in function

Enthusiastic react developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store