JavaScript assignment
Published: 2022-05-10 08:42:29

**What are the different data types present in javascript?**

- Boolean type.
- Null type.
- Undefined type.
- Number type.
- BigInt type.
- String type.
- Symbol type.

**Explain Hoisting in JavaScript.**
JavaScript Hoisting refers to the process whereby the interpreter appears to move the declaration of functions, variables or classes to the top of their scope, prior to execution of the code. Hoisting allows functions to be safely used in code before they are declared Explain passed by value and passed by reference.

**Difference between “==” and “===” operators.**
The difference between == and === is that: == converts the variable values to the same type before performing comparison. This is called type coercion. === does not do any type conversion (coercion) and returns true only if both values and types are identical for the two variables being compared.

**Explain Implicit Type Coercion in JavaScript.
**Implicit coercion happens when JavaScript coerces the value type to the expected type under the hood. This type of coercion happens without the developer noticing. Explicit coercion happens when we want to coerce the value type to a specific type.

**Is JavaScript a statically typed or a dynamically typed language?**
JavaScript is a dynamic language
JavaScript is called a dynamic language because it doesn't just have a few dynamic aspects, pretty much everything is dynamic. All variables are dynamic (both in type and exitance), and even the code is dynamic. You can create new variables at runtime, and the type of variables is determined at runtime.

**What is NaN property in JavaScript?**
In JavaScript, NaN stands for Not a Number. It represents a value which is not a valid number. It can be used to check whether a number entered is a valid number or not a number. To assign a variable to NaN value, we can use one of the two following ways. `var a = NaN var a = Number.NaN.`

** Explain passed by value and passed by reference.**
"Passing by value" means that you pass the actual value of the variable into the function. So, in your example, it would pass the value 9. "Passing by reference" means that you pass the variable itself into the function (not just the value). So, in your example, it would pass an integer object with the value of 9.

**What is an Immediately Invoked Function in JavaScript?**
An Immediately-invoked Function Expression is a way to execute functions immediately, as soon as they are created. IIFEs are very useful because they don't pollute the global object, and they are a simple way to isolate variables declarations

**Explain Higher Order Functions in JavaScript.**
In JavaScript, functions can be assigned to variables in the same way that strings or arrays can. They can be passed into other functions as parameters or returned from them as well. A “higher-order function” is a function that accepts functions as parameters and/or returns a function.

**Explain “this” keyword.**
The this keyword refers to the current object in a method or constructor. The most common use of the this keyword is to eliminate the confusion between class attributes and parameters with the same name (because a class attribute is shadowed by a method or constructor parameter).

**Explain call(), apply() and, bind() methods.**
The call() and apply() are very similar methods. They both execute the bound function on the object immediately. The bind() method does not execute the function right away. Instead, it creates and returns a bound function that can be executed later.

**What is Currying in JavaScript?**
In other terms, currying is when a function — instead of taking all arguments at one time — takes the first one and returns a new function, which takes the second one and returns a new function, which takes the third one, etc. until all arguments are completed

** Explain Scope and Scope Chain in JavaScript.**
Scope chains establish the scope for a given function. Each function defined has its own nested scope, and any function defined within another function has a local scope which is linked to the outer function — this link is called the chain.

**Explain Closures in JavaScript.**
A closure is the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment). In other words, a closure gives you access to an outer function's scope from an inner function.

**What are object prototypes?**
Prototypes are the mechanism by which JavaScript objects inherit features from one another. In this article, we explain what a prototype is, how prototype chains work, and how a prototype for an object can be set.

**What are callbacks?**
A callback is a function passed as an argument to another function

This technique allows a function to call another function

A callback function can run after another function has finished

**What is memoization?**
In programming, memoization is an optimization technique that makes applications more efficient and hence faster. It does this by storing computation results in cache, and retrieving that same information from the cache the next time it's needed instead of computing it again.

**What is recursion in a programming language?**
In computer science, recursion is a programming technique using function or algorithm that calls itself one or more times until a specified condition is met at which time the rest of each repetition is processed from the last one called to the first.

**What is the use of a constructor function in JavaScript?**
A constructor is a special function that creates and initializes an object instance of a class. In JavaScript, a constructor gets called when an object is created using the new keyword. The purpose of a constructor is to create a new object and set values for any existing object properties

**What is DOM?**
The Document Object Model (DOM) is a programming interface for web documents. It represents the page so that programs can change the document structure, style, and content. The DOM represents the document as nodes and objects; that way, programming languages can interact with the page.