DEV Community

loading...

10 Simple Javascript Interview Questions for All Beginners.

rahulghosh profile image Rahul Ghosh ・2 min read

1 Null Vs Undefined

A null means absence of a value. It means we can define a variable but have not assigned any value, so the value will be absent.
Otherside, Undefined is also a primitive value in JavaScript. A variable or an object has an undefined, when we have no value is assigned before we use it.

2 double equal (==) and triple equal (===) in javascript.

Double equals use for value equality. This means that before checking the values, it converts the types of the variables to match each other.
Triple equals do not perform type coercion. It will verify whether the variables compared have both the same value and the same type.

3 global variable, global scope

In JavaScript, there are two types of scope. Local scope Global scope. When variables are declared within a JavaScript function, it’s called local scope. In local scope, variables are only used only inside their functions
A variable declared outside a function, its called global scope. All other scripts and functions can access these global scope variables.

4 call(), apply() and bind() method

As functions are also objects in JavaScript, call(), apply() and bind() are used to control the function invocation. You can use call() or apply() to invoke the function immediately. bind() returns a bound function. So bind() can be used when the function needs to be called later.

5 let and const

ES6 introduced two new types of variable declarations in JavaScript.The keywords let and const. The let declarations is the same syntax as var declarations. Unlike variables declared with var, variables declared with let have a block-scope. let does not create any global property on the window. let reassignable and not redeclare.
Const is similar to var or let declarations. The const makes a variable a constant where its value cannot be changed. Const variables have the same scoping rules as let variables.

6 Arrow Function

In ES6, introduced us to write shorter function syntax which is Arrow functions. It allows us to create functions in a cleaner way similar to regular functions.
image1

7 DOM

DOM means Document Object Model. DOM is use for programming interface for HTML and XML documents. The DOM represents a document as a tree of nodes. The DOM is cross-platform and language-independent ways of manipulating DOM tree.

8 API

API means Application Programming Interface. An API is a set of functions that allows applications to access data and interact with external software components, operating systems, or microservices.

9 callback function

JavaScript runs code sequentially in top-down order. The way to create a callback function is to pass it as a parameter to another function, and then to call it back right after something has happened or some task is completed.

10 This keyword

In Javascript, this keyword is an important confusing keyword. In an object method, this refers to the owner of the method. It has different values depending on where it is used. This points to a particular object. Now, which is that object depends on how a function that includes 'this' keyword is being called.

Discussion (0)

Forem Open with the Forem app