Some Important method of javascript

Alamgir Hossain
4 min readMay 8, 2021


Javascript types

Truthy and Falsy: Truthy and falsy is a Boolean type value. It is used for the argument. Whenever needs to compare something between two values than true and false use.

False: There is six types of false value have. If that sixth type used somewhere then it will be a false value. That six types is.

  1. False: false is a false value.
  2. Undefined: If a value is undefined then it will be false.
  3. Null: If a value is Null then it will be falsy.
  4. NaN: If a value is NaN(Not a Number) then it also false.
  5. 0: If a value is 0 then it will be false.
  6. “”: If a value is an empty string “” then it will be false.

True: On the other hand all values will true except those false values.

Null and Undefined: Null and Undefined a type of javascript value. In different cases sometimes result show Null, sometimes Undefined. In JavaScript, undefined is a type, whereas null an object. It means a variable declared, but no value has been assigned a value. Whereas, null in JavaScript is an assignment value.

Null: Null is an Object in javascript. It is an assignment value. It means an empty.

Undefined: There are eight-time when the result will come as undefined.

  1. When a variable declares but the value not passed, then it will result as undefined.
  2. When a function has no return, then it will result as undefined. Also if return writes but value not pass then it also gives undefined.
  3. When the parameter declares but the value not give then it will show as undefined.
  4. When wanting a property but that not declare in an object, it will also give undefined.
  5. when want to find an index value from an array but that not have on that array it will result as undefined.
  6. Finally, if the value set as undefined then it will give an undefined result.

Double and Triple Equal: Double and Triple equal use for comparing two values and return true or false. But this two are not the same. The main difference between this two is double equal compare only two value where triple equal compare not only two values but also type of that two values.

Double Equal: In compare by double equal, it only compares two value whether it equal or not if equal then it will show true else will show false. It does not compare two values type, in this case, if I compare with 2 ==“2” then it will give an answer as true.

Triple Equal: It not only compares two values but also compares values type. For example, If I compare 2 === “2” then it will give the answer as false.

Binding Method: There are four types of binding. By this binding method, we will also find the “This” keyword indication object. They are:

  1. Implicit binding
  2. Explicit binding
  3. New binding
  4. Window binding

We will talk first two bindings only here

Implicit binding: In 80% case we use implicit binding to find out “This” keyword what object indicate. In this method first, identify where is function called. Then see if there have a dot before that function and if have then “This” keyword will mean before that dot object name


const player = function (obj) {
obj.outputPlayer = function () {
let alamgir = {
name: ‘Alamgir’,
age: 28
} // alamgir.outputPlayer();

Explicit binding: In this method there use some other methods like Call, Apply and Bind. In call() method parameter use comma-separated wherein apply method parameter use in an array and bind method is same as call() but it returns a function.

Call(): Call method used for different objects.


//call methodconst printName = function(h1, h2, h3) {
console.log(`My name is ${}, I’m ${this.age} Old. My Hobbies is ${h1}, ${h2}, ${h3}`);
}const Alamgir = {
name: ‘Alamgir’,
age: 28
}, ‘Do good work’, ‘Coding’, ‘Playing Cricket’)

Apply(): Apply method will do the same thing but it takes parameters in an array.


//applyprintName.apply(Alamgir, [‘Plying Cricket’, ‘Coding’, ‘Travelling’])

Scope: Scope defines the accessibility of variables. There is two types of scope. That is:

  1. Global scope
  2. Local scope

Global Scope: A variable declared outside a function became a global scope. And it will be accessible from anywhere.


let number = 10;Function add(){console.log(number)//result will show 10;}

Local Scope: A variable declared inside a function and only accessible inside that function is called a Local variable and it is a Local Scope.


Function add(){Let number = 20;console.log(number)//result will 20}

[Important: If a local variable is assigned without first being declared with the var keyword, it becomes a global variable. To avoid such unwanted behavior, you should always declare your local variables before you use them. Any variable declared with the var keyword inside a function is a local variable]

Synchronous: Synchronous means work serially. Javascript always works synchronously and single-threaded. Actually in default javascript works synchronously. But something works asynchronously.


function myFunction() {
console.log(‘i’m from synchronous’)
}console.log(‘i’m not asynchronous’)
console.log(‘i’m asynchronous’)
//Result will showI’m not asynchronous
I’m from synchronous
I’m asynchronous

Asynchronous: When using javascript build-in function setTimeout()then code will work asynchronously. Asynchronous means not work serially.


function myFunction() {
console.log(‘i’m from asynchronous’)
console.log(‘i’m not synchronous’)
console.log(‘i’m not asynchronous’)
//Result will show
i’m not synchronous
i’m not asynchronous
i’m from asynchronous



Alamgir Hossain

I'm a professional web- developer || JavaScript || React