How do you define instance and non-instance properties

Posted by Jessica Taylor | Updated on | JavaScript interview


The Instance properties must be defined inside of class methods. For example, name and age properties defined insider constructor as below: But Static(class) and prototype data properties must be defined outside of the ClassBody declaration. …

What are the differences between for…of and for…in statements

Posted by Jennifer | Updated on | JavaScript interview


Both for…in and for…of statements iterate over js data structures. The only difference is over what they iterate: for..in iterates over all enumerable property keys of an object for..of iterates over the values of an …

What are the built-in iterables

Posted by Jessica Taylor | Updated on | JavaScript interview


Below are the list of built-in iterables in javascript, Arrays and TypedArrays Strings: Iterate over each character or Unicode code-points Maps: iterate over its key-value pairs Sets: iterates over their elements arguments: An array-like special …

What are the differences between spread operator and rest parameter

Posted by Jennifer | Updated on | JavaScript interview


Rest parameter collects all remaining elements into an array. Whereas Spread operator allows iterables( arrays / objects / strings ) to be expanded into single arguments/elements. i.e, Rest parameter is opposite to the spread operator.

What are the differences between arguments object and rest parameter

Posted by Jennifer | Updated on | JavaScript interview


There are three main differences between arguments object and rest parameters The arguments object is an array-like but not an array. Whereas the rest parameters are array instances. The arguments object does not support methods …

How to detect if a function is called as constructor

Posted by Jessica Taylor | Updated on | JavaScript interview


You can use new.target pseudo-property to detect whether a function was called as a constructor(using the new operator) or as a regular function call. 1. If a constructor or function invoked using the new operator, …

How do you check an object is a promise or not

Posted by Jennifer | Updated on | JavaScript interview


If you don’t know if a value is a promise or not, wrapping the value as Promise.resolve(value) which returns a promise. Another way is to check for .then() handler type

What is a Proper Tail Call

Posted by Jennifer | Updated on | JavaScript interview


First, we should know about tail call before talking about “Proper Tail Call”. A tail call is a subroutine or function call performed as the final action of a calling function. Whereas Proper tail call(PTC) …

How do you make an object iterable in javascript

Posted by Jennifer | Updated on | JavaScript interview


By default, plain objects are not iterable. But you can make the object iterable by defining a Symbol.iterator property on it. Let’s demonstrate this with an example: The above process can be simplified using a …

What is deno

Posted by Jessica Taylor | Updated on | JavaScript interview


Deno is a simple, modern and secure runtime for JavaScript and TypeScript that uses V8 JavaScript engine and the Rust programming language.

What is an async function

Posted by Jennifer | Updated on | JavaScript interview


An async function is a function declared with the async keyword which enables asynchronous, promise-based behavior to be written in a cleaner style by avoiding promise chains. These functions can contain zero or more await …

What is the difference between function and class declarations

Posted by Jessica Taylor | Updated on | JavaScript interview


The main difference between function declarations and class declarations is hoisting. The function declarations are hoisted but not class declarations. Classes: Constructor Function:

What is an observable

Posted by Jennifer | Updated on | JavaScript interview


An Observable is basically a function that can return a stream of values either synchronously or asynchronously to an observer over time. The consumer can get the value by calling subscribe() method. Let’s look at …

What is the easiest way to resize an array

Posted by Jessica Taylor | Updated on | JavaScript interview


The length property of an array is useful to resize or empty an array quickly. Let’s apply length property on number array to resize the number of elements from 5 to 2, and the array …

What is a Short circuit condition

Posted by Jessica Taylor | Updated on | JavaScript interview


Short circuit conditions are meant for condensed way of writing simple if statements. Let’s demonstrate the scenario using an example. If you would like to login to a portal with an authentication condition, the expression …