Loading...

JAVASCRIPT

JavaScript is a programming language used to make web pages interactive and dynamic. It enables features like form validation, animations, and real-time content updates in browsers.

Basic Questions

Q1: What is JavaScript?
A programming language that adds dynamic behavior to websites.

Q2: Difference between let, var, and const?
var is function-scoped, let/const are block-scoped; const cannot be reassigned.

Q3: What is a function in JavaScript?
A block of code that performs a task when called.

Q4: What is an array?
A list-like object to store multiple values in one variable.

Q5: How to declare an object?
let obj = { name: 'John', age: 30 };

Q6: How to get element by ID in JS?
Use document.getElementById('id').

Q7: What is an event in JavaScript?
A user action like click, hover, submit, etc., that triggers a response.

Q8: How to convert JSON string to JS object?
Use JSON.parse(string).

Q9: What does setTimeout() do?
Delays code execution by a given number of milliseconds.

Q10: What is typeof operator?
Returns the data type of a variable (e.g., string, number).

Mid Level Questions

Q1: What is the DOM?
Document Object Model : allows JavaScript to manipulate HTML elements.

Q2: What is addEventListener()?
A method to attach event handlers to DOM elements.

Q3: What is a callback function?
A function passed as a parameter to be executed later.

Q4: Difference between == and ===?
== compares value (type-coerced), === checks value & type strictly.

Q5: What is a Promise in JS?
An object representing the eventual result of an async operation.

Q6: What is async/await?
Syntax that makes handling Promises easier and more readable.

Q7: What is localStorage?
Stores data in the browser permanently (until manually cleared).

Q8: What is NaN in JavaScript?
Stands for 'Not a Number', returned for invalid numeric operations.

Q9: Difference between null and undefined?
null is intentional no value; undefined means no value assigned.

Q10: Difference between forEach() and map()?
forEach() loops without return. map() returns a new array after transformation.