1. What are the different data types present in javascript?
- String
represents textual data
- Number
an integer or a floating-point number
- BigInt
an integer with arbitrary precision
Boolean
Any of two values: true or false
undefined
a data type whose variable is not initialized
null
denotes a null value
Symbol
data type whose instances are unique and immutable
Object
key-value pairs of collection of data
`
2. 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.
3. Difference between “==” and “===” operators.
= = in JavaScript is used for comparing two variables, but it ignores the datatype of variable.
= = = is used for comparing two variables, but this operator also checks datatype and compares two values.Checks the equality of two operands without considering their type.
4. Explain Implicit Type Coercion in javascript.
Implicit coercion happens when JavaScript coerces the value type to the expected type under the hood.
5. Is javascript a statically typed or a dynamically typed 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 existance), and even the code is dynamic.
6. What is NaN property in JavaScript?
In JavaScript, NaN stands for Not a Number. It represents a value which is not a valid number.
7. Explain passed by value and passed by reference.
you can pass by value and by reference. The main difference between the two is that passing by value happens when assigning primitives while passing by reference when assigning objects.
8. What is an Immediately Invoked Function in javascript?
An immediately invoked function expression is a programming language idiom which produces a lexical scope using function scoping.
9. Explain Higher Order Functions in javascript.
`A “higher-order function” is a function that accepts functions as parameters and/or returns a function.`
10. Explain “this” keyword.
“This” keyword refers to an object that is executing the current piece of code.
11. Explain call(), apply() and, bind() methods
- call()
It can be used to invoke (call) a method with an owner object as an argument (parameter).
- Apply()
you can write a method once, and then inherit it in another object, without having to rewrite the method for the new object
- bind()
The bind() method creates a new function, when invoked, has the this sets to a provided value.
12. What is Currying in javascript?
Currying is a process in functional programming in which we can transform a function with multiple arguments into a sequence of nesting functions. It returns a new function that expects the next argument inline.
13. Explain Scope and Scope Chain in javascript.
- Each
function creates a new scope. Variables defined inside a function are not accessible (visible) from outside the function
- while
scope chain is used to resolve the value of variable names in javascript.
14. Explain Closures in JavaScript
A closure is the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment)
15. What are object prototypes?
Prototypes are the mechanism by which JavaScript objects inherit features from one another.
16. What are callbacks?
A callback is a function passed as an argument to another function
17. What is memoization?
“Memoization is an optimization technique where expensive function calls are cached such that the result can be immediately returned the next time the function is called with the same arguments”
18. What is recursion in a programming language?
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.
19. what is the use of a constructor function in javascript?
The Function constructor creates a new Function object. Calling the constructor directly can create functions dynamically, but suffers from security and similar (but far less significant) performance issues to Global_Objects/eval
20. what is DOM?
DOM stands for Document Object Model. It is a programming interface that allows us to create, change, or remove elements from the document. We can also add events to these elements to make our page more dynamic.
Top comments (0)