10 Most impotent javaScript Question. you should have known.

Shahinur islam
2 min readMay 8, 2021

01.double equal (==) vs triple equal (===)

The simple way of saying that double equal (==) will not check types and triple equal (===) will check whether both sides are of the same type. if both sides are not the same type, the answer is always false. for example

var a = {a: 1};

var b = {a: 1};

a == b //false

a === b //false

var c = a;

a == c//true

a === c //true

02.Null Vs Undefined

What are the differences between null and undefined?

  • Null

Null means the empty or non-existent value which is used by programmers to indicate “no value”. null is a primitive value and you can assign null to any variable. null is not an object, it is a primitive value.

  • Undefined

Undefined means, the value of the variable is not defined. JavaScript has a global variable Undefined whose value is "undefined" and typeof Undefined is also "undefined".A declared variable without assigning any value to it.Implicit returns of functions due to missing return statements.return statements that do not explicitly return anything.Lookups of non-existent properties in an object.

03.Difference between bind, call and apply

  • Call invokes the function and allows you to pass in arguments one by one.
  • Apply invokes the function and allows you to pass in arguments as an array.
  • Bind returns a new function, allowing you to pass in this array and any number of arguments. For example

Call

const person1 = {firstName: 'shainur', lastName: 'islam'};

const person2 = {firstName: 'Monir', lastName: 'Khan'};

function say(greeting) {

console.log(greeting + ' ' + this.firstName + ' ' + this.lastName);

}

say.call(person1, 'Hello'); // Hello shainur islam

say.call(person2, 'Hello'); // Hello Monir Khan

Bind

const person1 = {firstName: ‘shainur’, lastName: ‘islam’};

const person2 = {firstName: ‘Monir’, lastName: ‘Khan’};

function say() {

console.log(‘Hello ‘ + this.firstName + ‘ ‘ + this.lastName);

}

const sayHelloshahinur = say.bind(person1);

const sayHelloMonir = say.bind(person2);

sayHelloshahinur(); //Hello shainur islam

sayHelloMonir(); //Hello Monir Khan

Apply

const person1 = {firstName: ‘shainur’, lastName: ‘islam’};

const person2 = {firstName: ‘Monir’, lastName: ‘Khan’};

function say(greeting) {

console.log(greeting + ‘ ‘ + this.firstName + ‘ ‘ + this.lastName);

}

say.apply(person1, [‘Hello’]); // Hello shainur islam

say.apply(person2, [‘Hello’]); // Hello Monir Khan

04.Asynchronous Javascript

JavaScript is a single-threaded programming language. Using asynchronous JavaScript (such as callbacks, promises, and async/await).For Example:

function added(some) {

document.getElementById(“demo”).innerHTML = some;

}

function myCalculator(num1, num2, myCallback) {

let sum = num1 + num2;

myCallback(sum);

}

myCalculator(5, 5, added); // value this 10

05.Recursive function

what is a Recursive function:

A recursive function is a function that calls itself during its execution.

How to work Recursive function for example:

--

--