1/54
These flashcards cover the core concepts of JavaScript, including console methods, variables, data types, operators, functions, objects, and more.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What is the primary purpose of the Console Object in JavaScript?
The Console Object is primarily used as a debugging tool that shows runtime execution and logs information.
What does console.log() do?
Outputs values to the console.
What is the difference between 'var', 'let', and 'const'?
'var' is function-scoped and hoisted, 'let' is block-scoped and can be reassigned but not redeclared, and 'const' is block-scoped and cannot be reassigned.
What is scope in JavaScript?
Scope refers to the accessibility of variables within different parts of code.
What is hoisting?
Hoisting is a JavaScript mechanism where variable declarations are processed before the code executes.
Name the primitive data types in JavaScript.
String, Number, Boolean, undefined, null, Symbol, BigInt.
What are the two types of operators in JavaScript?
Arithmetic and assignment operators.
What is type coercion?
Type coercion is the automatic or explicit conversion of values from one data type to another.
What are 'falsy' values in JavaScript?
Falsy values include false, 0, '', null, undefined, and NaN.
What are the advantages of using 'let' over 'var'?
'let' is block-scoped, preventing issues related to hoisting and variable redeclarations.
How do you create an object in JavaScript?
Objects can be created using object literals or constructors.
What is the purpose of the 'this' keyword in an object method?
'This' refers to the object that the method is called upon.
Define a higher-order function.
A higher-order function is a function that takes another function as an argument or returns a function as a result.
What is destructuring in JavaScript?
Destructuring allows you to extract values from arrays or properties from objects into distinct variables.
What does the spread operator do?
The spread operator expands an iterable (like an array) into more elements.
What is the difference between '==' and '==='?
'==' compares values with type coercion, while '===' compares both values and types without coercion.
What are asynchronous functions in JavaScript?
Asynchronous functions allow you to write code that performs tasks without blocking the execution of other code.
What is a promise in JavaScript?
A promise is an object that represents the eventual completion or failure of an asynchronous operation.
What is the purpose of the JSON object in JavaScript?
The JSON object is used to convert JavaScript objects to JSON strings and JSON strings back to JavaScript objects.
What does the fetch API do?
The fetch API allows you to make HTTP requests to servers and handle responses.
What is a callback function?
A callback function is a function passed into another function as an argument to be executed later.
Define event bubbling in JavaScript.
Event bubbling is a way of event propagation in the DOM where an event starts from the target element and bubbles up to its ancestors.
What is method chaining?
Method chaining allows multiple method calls on the same object in a single statement.
Explain what a pure function is.
A pure function is a function that always returns the same output for the same input and has no side effects.
What is hoisting in JavaScript?
Hoisting refers to the behavior of moving function and variable declarations to the top of their containing scope during the compile phase.
What is a constructor function in JavaScript?
A constructor function is a function used to create new objects and is defined with the 'new' keyword.
How can you access an array item in JavaScript?
You can access an array item by its index, using square brackets (e.g., array[index]).
What does 'Array.from()' do?
Array.from() creates a new Array instance from an array-like or iterable object.
What is a 'class' in JavaScript?
A class is a blueprint for creating objects, containing methods and properties.
What is inheritance in JavaScript?
Inheritance allows one class to inherit properties and methods from another class.
Explain the concept of 'modules' in JavaScript.
Modules are used to organize code, allowing encapsulation and reuse through export and import statements.
What is the difference between named and default exports?
Named exports allow you to export multiple values, while a default export allows only one value to be exported from a module.
What are 'getters' and 'setters' in JavaScript classes?
Getters and setters are special methods to define how properties should be accessed and mutated in an object.
What does the 'super' keyword do?
The 'super' keyword is used to call functions on an object's parent class.
Define an asynchronous function with async/await.
An async function is declared with 'async' and allows the use of 'await' to pause execution until a promise is resolved.
What is the purpose of the 'await' keyword?
'Await' is used to wait for a promise to resolve before continuing execution of the async function.
How do you handle errors in async functions?
Errors in async functions can be handled using try/catch blocks.
What is the purpose of console.warn()?
Outputs a warning message to the console.
How would you log an error message to the console in JavaScript?
Use console.error() to log an error message.
What is the method to display tabular data in the console?
console.table() is used to display tabular data.
How do you modify the text content of an HTML element using the DOM?
You can modify the text content using the textContent property.
What is the difference between .innerHTML and .textContent?
.innerHTML can read and update HTML content, while .textContent only deals with plain text.
What is the event object in an event listener?
The event object contains information about the event that occurred, such as properties and methods related to the event.
What does 'array.map()' do?
The array.map() method creates a new array populated with the results of calling a provided function on every element in the calling array.
What is the difference between .push() and .unshift() in arrays?
.push() adds an element to the end of an array, while .unshift() adds an element to the beginning.
What does .filter() do in an array?
.filter() creates a new array with all elements that pass the test implemented by the provided function.
What is the purpose of the .reduce() method?
.reduce() executes a reducer function on each element of the array, resulting in a single output value.
How can events be delegated in JavaScript?
Events can be delegated by adding a single event listener to a parent element that monitors events for its child elements.
What does 'parseInt()' do in JavaScript?
parseInt() converts a string to an integer.
What is the role of the 'return' statement in functions?
The return statement specifies the value to be returned from a function.
How can you convert a value to a number?
You can convert to a number using Number(), parseInt(), or parseFloat().
What is a callback hell?
Callback hell is a situation in JavaScript where callbacks are nested within other callbacks, leading to complex and hard-to-read code.
What does console.time() do?
console.time() starts a timer that can be used to measure the duration of a task.
What does console.timeEnd() do?
console.timeEnd() stops the timer that was started by console.time() and logs the elapsed time.
Explain what 'null' and 'undefined' represent in JavaScript.
'null' represents an intentional absence of any value, while 'undefined' indicates that a variable has been declared but not assigned a value.