Javascript Question
Javascript Question
Javascript Question
Javascript Question
Javascript Question
100

How do you declare a variable in JavaScript?

Using var, let, or const

100

What are data types in JavaScript?

  • String

  • Number

  • Boolean

  • Undefined

  • Null

  • BigInt

  • Symbol

100

What is the difference between == and ===?

== checks only value, while === checks value and type.

100

What is an array in JavaScript?

A collection of multiple values stored in a single variable.
let arr = [1, 2, 3, "hello"];

100

How do you check the data type of a variable?

Using typeof operator:

console.log(typeof 42); // "number"

console.log(typeof "Hello"); // "string"

200

What is an object in JavaScript?

A collection of key-value pairs.

let person = { name: "John", age: 25 };

console.log(person.name); // "John"

200

What is the this keyword?

Refers to the current object in different contexts.

200

What are template literals?

Strings with embedded expressions using backticks (``).

200

. How do you add elements to an array?

Using push() (adds to end) and unshift() (adds to start).

200

How do you remove elements from an array?

Using pop() (removes last) and shift() (removes first).

300

What is the difference between for and forEach loop?

  • for - Traditional loop for iterations.

  • forEach - Used on arrays for cleaner iteration.

300

What is a callback function?

A function passed as an argument to another function.

300

What is a promise in JavaScript?

A way to handle asynchronous operations.

300

How do you handle errors in JavaScript?

Using try...catch block.

300

What is the difference between map() and filter()?

  • map() - Transforms each element.

  • filter() - Filters elements based on a condition.

400

How do you convert a string to a number?

Using Number(), parseInt(), or parseFloat().

400

How do you check if a variable is an array?

Using Array.isArray().

400

How do you make an HTTP request in JavaScript?

Using fetch().

400

How do you remove duplicates from an array?

Using Set().

400

What is a closure in JavaScript?

A function that remembers the variables of its parent scope.

500

What is the spread operator?

Expands an array into individual elements.

let arr1 = [1, 2, 3];

let arr2 = [...arr1, 4, 5];

console.log(arr2);

500

What is the difference between for...in and for...of loops?

  • for...in - Iterates over object keys.

  • for...of - Iterates over values in an iterable like an array.

500

How do you merge two objects in JavaScript?

Using Object.assign() or spread operator.

500

What is the full form of (IIFE)?

Immediately Invoked Function Expression

500

What are JavaScript timers?

setTimeout() runs a function after a delay.
setInterval() runs a function repeatedly after a delay.

M
e
n
u