Jump into JavaScript niche topics that you might skip!

Kazi Minhajul Haider
3 min readMay 8, 2021

--

01. Truthy and Falsy:

The value which consider as a true when encountered in a Boolean context
On the other hand the value which consider as a true when encountered in a Boolean context. Now according to MDN documentation there can be 9 falsy value. here is the list

Complete list of JavaScript falsy values

Except these 9 case all the cases will give you truthy value.

02. Null vs Undefined:

Null and undefined create a confusion among the JavaScript developers. So I got a simple example from a stack overflow which helped to understand very easily. Lets see the example from stack overflow,

here you can see that we declared a variable named “name” and we did not assign a value into this. Now if we see the out put then we will see that it gives undefined. It means when we create a variable and not assign a value it returns a undefined result. The typeOf undefined is “undefined”

Now look at a null example,

here, we declared a variable and assigned it a null variable. Null is a object in JavaScript. We can put this null object into a variable to indicate that there is not value.

03. Double equal (==) vs Triple (===) :
Double equal ( == ) also known as lenient or loose equal and triple equal ( = = = ) know as strict equal. Well The main theme is double equal (==) checks the value only, even if the type if different double equal wont bother. for example :

On the other hand triple equal ( = = = ) compares both value and type. This checking is more reliable and it gives your desire output every time. For example,

Modern developer often use triple equal for better and accurate performance.

04. Global Scope vs Local Scope:

When we declare a variable outside of a function then it becomes global variable and when we declare a function inside a function then it becomes a local variable. We can access the global variable from any corner but we can only local variable inside of the function. Anything in the global scope could be accessible across your application

global scope example

Local scope is a characteristic of variables that makes them local. local variable are not available every where. Rather its only available into the function. Lets see an example:

--

--

Kazi Minhajul Haider