Javascript Flashcards
What is ECMAScript in JavaScript?
ECMAScript (or ES) is the standard specification for JavaScript that defines the core features and syntax of the language. JavaScript is the most popular implementation of ECMAScript.
What is the difference between let, const, and var in JavaScript?
var declares variables with function scope.
let declares variables with block scope (ES6).
const declares constants with block scope, whose value cannot be reassigned once defined.
What is the spread operator, rest operator, and default parameter in JavaScript?
Spread (…) operator: Used to expand iterable objects into multiple elements.
Rest (…) parameter: Collects multiple arguments into an array.
Default parameter: Allows function parameters to have default values if not provided.
What is deep copy and shallow copy in JavaScript?
Deep copy: Creates a copy of nested objects and their values recursively.
Shallow copy: Copies the top-level structure of objects, with references to nested objects (not deeply cloned).
What are promises, callback functions, async/await in JavaScript?
Promises: Objects representing the eventual completion (or failure) of an asynchronous operation.
Callback functions: Functions passed as arguments to another function, to be executed later.
async/await: Asynchronous JavaScript feature that simplifies writing asynchronous code using promises.
What is the difference between a promise and a callback in JavaScript?
Promises provide a cleaner way to handle asynchronous operations compared to nested callbacks, offering better error handling and sequential chaining.
What is event bubbling and event capturing in JavaScript?
Event bubbling: When an event occurs on a nested element, it triggers parent elements in the DOM hierarchy.
Event capturing: The opposite process, where events are captured starting from the outermost parent down to the target element.
What is a higher-order function in JavaScript?
A higher-order function is a function that either takes another function as an argument or returns a function as a result. Examples include map, filter, reduce.
Explain different types of functions in JavaScript?
JavaScript functions include function declarations, function expressions, arrow functions, and generator functions, each with specific use cases and syntax.
What is an arrow function in JavaScript?
Arrow functions are concise function syntax introduced in ES6, providing a shorter syntax for writing function expressions. They use a fat arrow (=>) and have implicit return.
Why do we use call, apply, and bind methods in JavaScript?
call, apply, and bind are methods used to manipulate the context (this value) of a function, allowing explicit setting of this and passing arguments.
How many ways to create objects in JavaScript?
Objects in JavaScript can be created using object literals, constructor functions (new Object()), classes (ES6), and Object.create() method.
What is prototype inheritance in JavaScript?
Prototype inheritance is the mechanism where objects inherit properties and methods from a prototype object, forming a prototype chain. It allows objects to share behavior and avoid redundancy.
What is TypeScript?
TypeScript is a superset of JavaScript that adds static typing, interfaces, and other features for building large-scale applications. It compiles to plain JavaScript.
What are array methods and string methods in JavaScript?
Array methods (map, filter, reduce, forEach, etc.) and string methods (toUpperCase(), substring(), indexOf(), split(), etc.) provide functionalities to manipulate arrays and strings.