JavaScript

--

If else example:

Const age = 20;

If(age){

Console.log(“this value is true”);

}

else{

Console.log(“this value is false”);

}

If the value is 0, “” , undefined, null, NaN, false. This is value is false.

Null vs undefined

The undefined value is not set. If the variable doesn't declare. value is undefined.

An undefined value is set.

For example:

Const name: null;

Double equal (==) or triple equal (===)

Double equal checking this value.

Triple equal checking value and type.

javaScript Function Scope

In javaScript there are two types :

· Local scope

· Globale scope

Variables declared within a javaScript function, become local to the function.

function myFunction() {
var carName = “Volvo”;

// code here

}

A variable declared outside a function becomes global.

var carName = “Volvo”;

// code here

function myFunction() {

// code here

}

--

--

Ridoy Karmakar
0 Followers

web developer