JavaScript Core Concepts

0.0(0)
studied byStudied by 2 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/49

flashcard set

Earn XP

Description and Tags

A set of flashcards covering core concepts in JavaScript.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

50 Terms

1
New cards

What is the primary purpose of the Console Object in JavaScript?

To serve as a debugging tool that shows runtime execution and logs information.

2
New cards

Which console method is used for logging errors?

console.error()

3
New cards

Which console method is best for measuring performance of code execution?

console.time() and console.timeEnd()

4
New cards

What is the primary advantage of using console.table()?

It displays data in a tabular format for easier reading.

5
New cards

What is the main difference between 'let' and 'var' in JavaScript?

'let' is block-scoped while 'var' is function-scoped.

6
New cards

Which of the following is true about 'const'?

It prevents reassignment of the variable but object properties can still be modified.

7
New cards

What does hoisting in JavaScript refer to?

A mechanism where variable and function declarations are processed before code execution.

8
New cards

Which of the following is a valid use of the 'const' declaration?

const x = {name: 'John'}; x.name = 'Jane';

9
New cards

Which of the following is NOT a primitive data type in JavaScript?

Array.

10
New cards

What is the result of typeof null in JavaScript?

"object".

11
New cards

Which data type is used for representing very large integers beyond the limits of Number?

BigInt.

12
New cards

What is the main difference between null and undefined?

null represents an intentional absence of value, while undefined indicates a variable has been declared but not assigned a value.

13
New cards

What is the result of '5' + 3 in JavaScript?

'53'.

14
New cards

What does the === operator check for?

Value and type equality (strict equality).

15
New cards

What are 'falsy' values in JavaScript?

false, 0, empty strings, null, undefined, and NaN.

16
New cards

What is short-circuit evaluation in JavaScript?

Using && and || operators to conditionally execute code based on truthiness.

17
New cards

What is a higher-order function?

A function that takes another function as an argument or returns a function.

18
New cards

What is the difference between function declarations and function expressions?

Function declarations can be called before they're defined (hoisted), while function expressions cannot.

19
New cards

What is a pure function?

A function that always returns the same output for the same input and has no side effects.

20
New cards

What is a valid arrow function that adds two numbers?

const add = (a, b) => a + b.

21
New cards

What method would you use to create a new array with elements that pass a test?

array.filter().

22
New cards

What is the correct way to access a property named 'user-id' in an object?

obj['user-id'].

23
New cards

What does the spread operator (…) do when used with arrays?

Expands an array into individual elements.

24
New cards

Which array method would you use to transform each element in an array into a new value?

map().

25
New cards

What is destructuring in JavaScript?

A technique to extract values from arrays or properties from objects into distinct variables.

26
New cards

What is the purpose of the constructor() method in a class?

To initialize new object instances of the class.

27
New cards

What does the 'extends' keyword do in a class declaration?

Creates a child class that inherits from a parent class.

28
New cards

What is the 'super' keyword used for in a class?

To call methods from the parent class or constructor.

29
New cards

What is a static method in a class?

A method that is called on the class itself, not on instances.

30
New cards

What is the main difference between a class and a constructor function in JavaScript?

Classes are just syntactic sugar over constructor functions and prototypal inheritance.

31
New cards

What is the primary purpose of JavaScript modules?

To organize code, encapsulate functionality, and manage dependencies.

32
New cards

What is the difference between named exports and default exports?

Named exports can export multiple values, while default exports can only export one value per module.

33
New cards

What is the correct way to import a default export?

import name from './file.js'.

34
New cards

What are namespace imports in JavaScript modules?

Importing all exports from a module into a single object.

35
New cards

What is the difference between querySelector() and getElementById()?

querySelector() can select elements using CSS selectors, while getElementById() only selects by ID.

36
New cards

What is the difference between textContent and innerHTML?

innerHTML can read and update HTML content, while textContent only deals with plain text.

37
New cards

What is event delegation in JavaScript?

Adding a single event listener to a parent element that handles events for its children.

38
New cards

What does the classList property provide?

A way to add, remove, and toggle classes on an element.

39
New cards

What is a Promise in JavaScript?

An object that represents the eventual completion or failure of an asynchronous operation.

40
New cards

What is the purpose of the 'await' keyword?

To pause execution until a Promise is resolved.

41
New cards

How do you handle errors in async/await code?

Using try/catch blocks.

42
New cards

What is the callback hell problem?

When nested callbacks become unmanageable, creating deeply nested code.

43
New cards

What is the purpose of JSON.stringify()?

To convert a JavaScript object into a JSON string.

44
New cards

What does the fetch API return initially?

A Promise that resolves to the Response object.

45
New cards

What is the correct way to parse a JSON string into a JavaScript object?

JSON.parse().

46
New cards

What is the main advantage of using Promise.all()?

It handles multiple promises together and waits for all of them to resolve.

47
New cards

What do we call the state of a Promise before it is either fulfilled or rejected?

Pending.

48
New cards

Which HTTP method is used by default in the fetch API?

GET.

49
New cards

What is the difference between synchronous and asynchronous code execution?

Synchronous code blocks execution until completed, while asynchronous code allows other code to run while waiting.

50
New cards

What is the purpose of Promise.race()?

To return the result of the first promise that resolves or rejects.