javascript_interview_questions
javascript_interview_questions
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