Some javascript concepts which helps to jobs interview.

Muhammad Rifat
3 min readMay 8, 2021

Learn about Javascript

Truthy and Falsy values:
Falsy values:
1. false.
2. null.
3. undefined.
4. 0 (Both positive and negative)
5. ‘’.
6. NaN.

Truthy values:
1. true.
2. 10. (any numbers)
3. ‘false’. (Non-empty string)
4. {}
5. []
7. new Date()
8. Infinity.

Null vs Undefined:
1. null is an object but undefined is a type.
2. null is an assignment value that assigns it to a variable whereas undefined means a variable declared, but no value has been assigned.

Double equals (==) vs Triple equals (===):
1. Double equals (==) checks only values, do not types whereas Triple equals (===) checks both values and types.
2. Example:
const num1 = 15;
const num2 = ‘15’;

console.log(num1 == num2); // true
console.log(num1 === num2); // false

Scope:
Scope determines the accessibility (visibility) of variables. It defines where we can access variables in the program.

Local variables:
When variables declared within a function are called local variables. Local variables have Function Scope, they can be accessed only within a function.
Example:

Global variables:
When variables declared outside of a function are called global variables. Global variables have Global Scope, they can be accessed from all functions and can be used from anywhere of program.

Diff. between bind, call, and apply:
call():
call() method used for accessing an object value in a function. It invokes a function with a given ‘this’ value and parameter passed one by one.
Example:

apply():
apply() method invokes a function and allows to the passed parameter as an array.
Example:

bind():
bind() method doesn’t call invokes the function, it creates an instance of invokes the function.
It returns a new function and allows to pass parameters both one by one and array.
Example:

Encapsulation:
Encapsulation is a process of binding the variables and methods. It allows to control the variables and methods. In javascript class, we can declare variables and methods with private and public. Private variables or methods only access within own class, and public variables or methods accessed from any extended classes which inherite main class.

this keyword:
this keyword refers to an object, and it has different values depending on where it is used. when does not pass any object in a function, this refers to the global object[window object] in this function.

setTimeout():
It executes a specified block of code for one time after a specified time has finished.
Javascript engine executes inside code of setTimeout() when all works have executed.
Example:

setInterval():
If any specified block of code needs to execute in a certain time, then used to setInterval() method.
Example:

--

--

Muhammad Rifat

I'm a developer with a vast array of knowledge in many different front-end and back-end languages, responsive frameworks, databases, and best code practices.