-
There are 6 primitive data types:
- string
- number
- bigint
- boolean
- undefined
- symbol
-
undefined
is a variable that has been declared but no value exists and is a type of itself ‘undefined’.null
is a value of a variable and is a type of object.A variable is
undeclared
when it does not use the var keyword. It gets created on the global object, thus it operates in a different space as the declared variables.
-
-
== abstract equality operator
=== strict equality operatorThe == operator will compare for equality after doing any necessary type conversions. The === operator will not do the conversion, so if two values are not the same type === will simply return false. Both are equally quick.
-
Ternary means operands with three parameter. This is a one-line shorthand for an if-else statement. It is also called a conditional operator.
conditional ? truethy_block : falsey_block
-
-
-
Destructuring is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.
Below is the example of Array Destructuring.
let array = ["Javascript", "is", "awesome", "😍"]; let [firstEle, secondEle] = array; console.log(firstEle);//"Javascript" console.log(secondEle);//"is"
Below is the example of Object Destructuring.
let car = { name: "Model S", brand: "Tesla", type: "e-Vehicle" }; let {name, brand, type} = car; console.log(name);//"Model S" console.log(brand);//"Tesla" console.log(type);//"e-Vehicle""
-
For iterating over array :-
- for loop
- forEach
- every
- some
- map
- filter
- reduce
For iterating object properties :-
- for...in
- Object.getOwnPropertyNames()
-
Can you describe the main difference between the Array.forEach() loop and Array.map() methods and why you would pick one versus the other?
The Array.forEach() method receives a function as an argument and executes it once for each array element. It returns
undefined
.The Array.map() method receives a function as a argument. Then it applies it on each element and returns an
entirely new array
populated with the results of calling the provided function.
-
In While
(Entry Control)
loop, the condition tested at the beginning of the loop, and if the condition is True, statements inside the loop will execute. It means the While loop executes the code block only if the condition is True.In Do While
(Exit Control)
loop, the condition is tested at the end. So, Do While executes the statements in the code block at least once even if the condition Fails.
-
A programming language is said to have First-class functions when functions in that language are treated like any other variable. In such a language, a function can be assigned as a value to a variable, can be passed as an argument to other functions, and can be returned by another function. Javascript supports First-class functions, In JavaScript functions are a special type of object.
-
A higher-order function is a function that accepts functions as parameters and/or returns a function.
Read this article Understanding Higher-Order Functions in JavaScript for deep understanding.
-
-
This article JavaScript - Event order on quirksmode is a very good resource to understand event bubbling and capturing in detail.
-
Event delegation allows us to add event listeners to the parent instead of having to add event listeners individually for each child. It uses
event bubbling
, where the event on the child is bubbled up to the parent. When the event bubbles up to the parent element, we can check the event object's target property to gain a reference to the actually clicked child element. This becomes more handy when child elements are frequently added and removed from the parent element.
-
-
-
-
-
Can you explain what Function.call and Function.apply do? What's the notable difference between the two?
Both Function.prototype.call and Function.prototype.apply are used to set the value of
this
explicitly. While call takes a list of arguments in comma separated format, apply takes an array with list of arguments.
-
Function.prototype.bind is used to set
this
explicitly. It returns a function with given this context that can be called later.
-
-
-
-
Explain the difference between: function Person(){}, var person = Person(), and var person = new Person()?
-
-
-
-
-
-
-
What are some of the advantages/disadvantages of writing JavaScript code in a language that compiles to JavaScript?
-
- What is an example of an immutable object in JavaScript?
- What are the pros and cons of immutability?
- How can you achieve immutability in your own code?
-
-
-
-
Can you offer a use case for the new arrow => function syntax? How does this new syntax differ from other functions?
-
-
-
-