Most common JavaScript interview question

The most common JavaScript interview question that we should have known for all. Firstly I will prefer Data Types. Data Types are a common cause that we use most of the time. Let's start….

Truthy and Falsy values:

cosnt Money = ""; //this value return false
cosnt Money = ; //this value return false
cosnt Money = "100"; //this value return true

Null Vs Undefined:

cosnt Money ; //this value return undefiend
cosnt Money = ""; //this value return null

Which return value of boolean:

        a=3; 
b=4;
(a < b) // return value will be false
(a > b) // return value will be true

Which difference of (==) and (===) :

a=3; 
b=4;
(a < b) // return value will be false
(a > b) // return value will be true

Function vs Arrow Function :

a=3; 
b=4;
function sum(a,b){ // simple function
return a+b
}
const sum=(a,b)=>{return a+b} //arrow function

How to easily copy multiple parameters in a function :

function sum(a,b,...rest){ // its set in last of required parameter
return a+b*rest
}

Introduction of some Scope, block scope, access outer scope variable:

function sum(a,b,...rest){ 
return result = a+b*rest
}
console.log(result) //here you will get error for scope variable

Closure, encapsulation, private variable :

function sum(a,b,...rest){ 
return const result = ()=>{a+b*rest }
}
console.log(result(2,5)) //here use to closure

Object how to work:

const you = {name:"john due",age:29,occupation:"freelancer"
}
console.log(you.name) //return your name only

Which Es6 feature you like most:

// arrow function
//var not use, use let const
//ternary operator
//...rest operator

Javascript programmer and learn more