JAVASCRIPT INTERVIEW QUESTIONS FOR FRESHER.
JAVASCRIPT INTERVIEW QUESTIONS FOR FRESHER.
data Types.
Check the type of data to use typeof() operator.
String
Number
Boolean
Bigint
Undefined
Object
null
Explain Hoisting in javascript.
Hoisting is the default behavior of javascript where all the variable and function declarations are moved on top.
Difference between “ == “ and “ === “ operators
Both are comparison operators. The difference between both the operators is that “==” is used to compare values whereas, “ === “ is used to compare both values and types
Difference between var and let keyword in javascript.
Variables declared by let are only available inside the block where they're defined. Variables declared by var are available throughout the function in which they're declared
Is javascript a statically typed or a dynamically typed language? JavaScript is a dynamically typed language. In a dynamically typed language, the type of a variable is checked during run-time in contrast to a statically typed language, where the type of a variable is checked during compile-time.
What is NaN property in JavaScript?
NaN property represents the “Not-a-Number” value. It indicates a value that is not a legal number. typeof of NaN will return a Number.
Explain passed by value and passed by reference.
In JavaScript, primitive data types are passed by value and non-primitive data types are passed by reference.
Explain Higher Order Functions in javascript.
Functions that operate on other functions, either by taking them as arguments or by returning them, are called higher-order functions.
function higherOrder2() { return function() { return "Do something"; } }
var x = higherOrder2(); x() // Returns "Do something"
Explain “this” keyword.
The “this” keyword refers to the object that the function is a property of.The value of the “this” keyword will always depend on the object that is invoking the function.
There are three types of scopes in JS:
Global Scope: Variables or functions declared in the global namespace have global scope,
Function Scope: Any variables or functions declared inside a function have local/function scope,
Block Scope: Block scope is related to the variables declared using let and const.
Explain Closures in JavaScript.
Closures are an ability of a function to remember the variables and functions that are declared in its outer scope.
var Person = function(pName){
var name = pName; this.getName = function(){ return name; } }
var person = new Person("Neelesh");
console.log(person.getName());
What is a callback : A callback is a function that will be executed after another function gets executed.
What are the types of errors in javascript?
Syntax error: Syntax errors are mistakes or spelling problems in the code
Logical error: Reasoning mistakes occur when the syntax is proper but the logic or program is incorrect.
What is recursion in a programming language?
Recursion is a technique to iterate over an operation by having a function call
What is the use of a constructor function in javascript?
Constructor functions are used to create objects in javascript.
No comments: