100 JavaScript Interview Questions and Solutions
## 1. Basic JavaScript Questions
### 1.1 What are the different data types in JavaScript?
Explanation: JavaScript has 8 basic data types: Number, String,
Boolean, Undefined, Null, Object, Symbol, and BigInt.
Code Example:
const types = [
typeof 42, // "number"
typeof "Hello", // "string"
typeof true, // "boolean"
typeof undefined, // "undefined"
typeof null, // "object"
typeof Symbol("symbol"), // "symbol"
typeof {}, // "object"
typeof [], // "object"
typeof function(){} // "function"
];
console.log(types);
...
### 1.2 What is the difference between `var`, `let`, and `const`?
Explanation: `var` is function-scoped, `let` and `const` are
block-scoped. `const` cannot be reassigned.
Code Example:
var a = 10; // Function-scoped, can be re-declared
let b = 20; // Block-scoped, cannot be re-declared in same scope
const c = 30; // Block-scoped, cannot be re-assigned
... (other questions and answers will follow in the PDF)