Recap Some JavaScript Tricky and Interview Topics.

Tania Akter
3 min readMay 19, 2021

Truthy and Falsy: In JavaScript truthy expression generate a true value, falsy expression generates a boolean false value. There is a list of falsy values, like null, undefined, NaN, “ ”, ‘’, 0, 0n. Left of the values is truth.

Null Vs Undefined: Undefined is the variable of a primitive type. When assigned a variable but did not initialize it can throw a type error undefined. If a function has a parameter but calls the function without any argument then it also shows the undefined error. Null is an intentionally declare value. The type of Null is an object, So the null value can not check the type.

Closure: A closure is an inner function that has access to the outer function’s variables. The outer function can not access the inner function variable. IN the closure has three scopes, Global Scope, Outer function scope, and Inner scope. The closure is used for object data privacy, event handlers, callback functions.

bind() method: If a JavaScript object has a method, this method can use on other objects by calling the bind method and use it so many times. For using this object method on other objects must use this keyword in the main object's method.

call() method: call() method also use object method. It calls the object method directly without reference. For invoking the call method past the arguments, the first argument will be which object wants to use that object's name. If the method has any parameter that parameter also sends by using a comma after the first arguments.

apply() method: apply method is the same as the call method. It also uses the object method directly. The difference between call and apply that its arguments pass the use of an array.

this Keyword: The javascript this keyword refers to the object it belongs to. When this use alone it refers to the global object. If this use in a object it will refer the owner of the method. In a JavaScript function, the owner of the function is the default binding for this. So in a function this refers the global objects. In a function strict mode this will be undefined.

Async and Await: The word async before a function means that function always return a promise. Other values are wrapped in a resolved promise automatically. There’s another keyword, await that works only inside async functions. The keyword await makes JavaScript wait until that promise settles and returns its result.

setTimeout and setInterval: The setTimeout() method calls a function or an expression after a specified time of milliseconds. This method break the synchronus flow and make it asynchronus. setIntervals is same as setTimeout but it does not execulte program for once. It executes regularly after the given interval of time.

new Keyword: The new keyword create an instance of a user-defined object type or of one of the built-in object types that has a constructor function. It creates new empty object. It sets new empty object’s invisible ‘prototype’ property to be the constructor function’s visible and accessible ‘prototype’ property. It binds property or function which is declared with this keyword to the new object.

--

--