More About Javascript. You Should Know.

Monsur Rana
2 min readMay 8, 2021

1.Javascript Truthy Value

In JavaScript, a truthy value is a value that is considered true when encountered in a Boolean context. All values are truthy unless they are defined as falsy and these are like,

"0"," ", {}, []

2.Javascript Falsy Value

A falsy (sometimes written falsy) value is a value that is considered false when encountered in a Boolean context.

the keyword false,
the number 0,
the number -0,
the empty string value, "",'', ``
null,
undefiend,
NaN

3.Null

The value null represents the intentional absence of any object value. It is one of JavaScript's primitive values and is treated as falsy for boolean operations.

4. (==) double equal

double equals (==) will perform a type conversion when comparing two things and will handle NaN, -0, and +0 especially to conform to IEEE 754 (so NaN != NaN, and -0 == +0).double equals will check the declared variable and the comparison element. if the variable and the comparison element are for the most part are similar then double equal makes both one component. double equal change one type to another type. Like, the variable is a number and the comparison is a number type string then it checks both of them. if the number and the number which is on the string are the same, then double equal make those one type like a number or a string.

5. (===) triple equal

triple equals (===) will do the same comparison as double equals (including the special handling for NaN, -0, and +0) but without type conversion; if the types differ, false is returned. triple equals will check the declared variable and the comparison element like double equal but, triple equal is strict. triple equal will check if the variable and the comparison element are actually the same are. if not, this will show an error. because triple equal is checking the variable and the comparison element is exactly the same. if a variable is a number and the comparison type is a number type string, then triple equal will gave us an error.

6.Scope

A function serves as a closure in JavaScript, and thus creates a scope, so that (for example) a variable defined exclusively within the function cannot be accessed from outside the function or within other functions. For instance, the following is invalid:

function exampleFunction() {
var x = "declared inside function"; // x can only be used in exampleFunction
console.log("Inside function");
console.log(x);
}

console.log(x); // Causes error

7.Closer

If there is another function within a function, then if we return or use the second function, it creates a closed environment and leaves an external reference of its own.

function makeAdder(x) {
return function(y) {
return x + y;
};
}

var add5 = makeAdder(5);
var add10 = makeAdder(10);

console.log(add5(2)); // 7
console.log(add10(2));

--

--

Monsur Rana
0 Followers

the biggest risk is not take any risk