10 Most impotent javaScript Question. you should have known.

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

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

How to work Recursive function for example:

--

--

--

Junior Front End Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Introduction to TypeScript Utility Types: Part Two

React Visual Editors in 2020

An Amateur Approach to JSON Mock Server and Local Data Storage for API Testing

Best Redux architecture explained in 5 minutes.

Introduction To React

RxJS retryWhen use-case in iframe-d Angular SPA

9 Ways JavaScript Can Drive You Crazy

Using React Testing Library to test if component contains an instance of another component

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Shahinur islam

Shahinur islam

Junior Front End Developer

More from Medium

My first “blog” as a WebDev

What is JavaScript?

“.this” could get ugly.

How to Build “Wordle” Using ReactJS and About 200 Lines of Sloppy Code