JavaScript Interview 50 QA
JavaScript Interview 50 QA
A1: '==' compares values after type coercion, whereas '===' compares both value and type without
coercion.
A2: A closure is a function that has access to its own scope, the outer function's scope, and the
A3: The event loop handles asynchronous operations by placing them in a queue and executing
A4: Hoisting is JavaScript's behavior of moving declarations to the top of the current scope before
code execution.
A5: Promises represent the eventual completion (or failure) of an asynchronous operation and its
resulting value.
A6: 'var' is function-scoped, 'let' and 'const' are block-scoped. 'const' cannot be reassigned.
A7: A callback is a function passed into another function as an argument to be executed later.
A8: 'null' is an assigned value representing no value. 'undefined' means a variable has been
declared but not assigned a value.
A9: 'this' refers to the object it belongs to, and its value depends on how the function is called.
A10: An object is a collection of key-value pairs, where values can be any type.
A11: Every JavaScript object has a prototype, from which it can inherit properties and methods.
A12: 'call()' and 'apply()' invoke a function with a given 'this' context. 'bind()' returns a new function
A13: Event delegation is a technique of handling events at a higher level in the DOM to manage
A14: Synchronous code is executed sequentially, while asynchronous code can be executed without
A15: 'async' declares a function that returns a promise. 'await' pauses execution until the promise is
resolved.
A16: Arrow functions are a shorter syntax for writing functions, and they do not have their own 'this'.
variables.
A18: The spread operator (...) allows an iterable to be expanded in places where zero or more
A19: The rest parameter allows representing an indefinite number of arguments as an array.
A21: Template literals allow embedded expressions and multi-line strings using backticks (` `).
A24: 'forEach' executes a function for each array element. 'map' returns a new array with results.
A25: A pure function returns the same result for the same input and does not cause side effects.
A26: Immutability means that an object's state cannot be modified after it is created.
A28: Shallow copy copies references to nested objects. Deep copy duplicates all levels.
A29: Falsy values include false, 0, '', null, undefined, and NaN.
A30: NaN stands for 'Not-a-Number'. It's a value representing undefined or unrepresentable
mathematical operations.
A31: JavaScript uses automatic garbage collection to reclaim memory occupied by unreachable
objects.
A32: Modules allow splitting code into reusable pieces. ES6 introduced 'import' and 'export' syntax.
A34: Currying transforms a function with multiple arguments into a sequence of functions each
A35: Symbols are unique and immutable primitive values often used as object property keys.
A36: Optional chaining (?.) allows reading nested object properties without checking each level
manually.
A37: The nullish coalescing operator (??) returns the right-hand operand when the left is null or
undefined.
A38: Debounce limits the rate at which a function is executed by delaying it until after a pause.
A39: Throttle limits the execution of a function to once every specified time interval.
A40: Web APIs are built-in browser APIs for tasks like DOM manipulation, HTTP requests, timers,
etc.
A41: localStorage allows storing key-value pairs in a web browser with no expiration.
A42: sessionStorage is similar to localStorage but is cleared when the session ends.
A43: 'innerHTML' gets/sets HTML content, while 'innerText' deals with visible text content only.
A44: DOM (Document Object Model) is a programming interface for HTML and XML documents.
A45: Event bubbling propagates events from child to parent, while capturing is from parent to child.
keyword.
A48: A Map is a collection of key-value pairs where keys can be of any type.
A49: JSON (JavaScript Object Notation) is a lightweight format for storing and transporting data.
A50: Default parameters allow function parameters to have default values if no value is passed.
A51: The 'typeof' operator returns a string indicating the type of the operand.