101 Flashcards

1
Q

What is JavaScript?

A

JavaScript is a high-level, dynamic, untyped, and interpreted programming language used primarily for web development.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

True or False: JavaScript is a compiled language.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does the ‘var’ keyword do in JavaScript?

A

The ‘var’ keyword declares a variable that is function-scoped or globally-scoped.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Fill in the blank: In JavaScript, a _______ is a collection of key-value pairs.

A

Object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the purpose of the ‘console.log()’ function?

A

The ‘console.log()’ function outputs messages to the web console, useful for debugging.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is an array in JavaScript?

A

An array is a data structure that can hold multiple values in a single variable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which symbol is used to denote a single-line comment in JavaScript?

A

//

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the result of 5 + ‘5’ in JavaScript?

A

‘55’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

True or False: JavaScript is case-sensitive.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does DOM stand for?

A

Document Object Model

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are JavaScript functions?

A

Functions are reusable blocks of code that perform a specific task.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What keyword is used to define a constant in JavaScript?

A

const

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the difference between ‘==’ and ‘===’ in JavaScript?

A

’==’ checks for value equality with type coercion, while ‘===’ checks for both value and type equality.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Fill in the blank: JavaScript uses _______ to handle asynchronous operations.

A

Promises

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a closure in JavaScript?

A

A closure is a function that retains access to its lexical scope, even when the function is executed outside that scope.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Which method is used to convert a JSON string into a JavaScript object?

A

JSON.parse()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What does the ‘this’ keyword refer to in JavaScript?

A

‘this’ refers to the context in which a function is executed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is the purpose of the ‘try…catch’ statement?

A

The ‘try…catch’ statement is used to handle exceptions and errors gracefully.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is a promise in JavaScript?

A

A promise is an object that represents the eventual completion or failure of an asynchronous operation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

True or False: JavaScript supports object-oriented programming.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is event bubbling in JavaScript?

A

Event bubbling is a type of event propagation where the event moves from the target element up to the root of the DOM.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What does the ‘map()’ method do in JavaScript?

A

The ‘map()’ method creates a new array populated with the results of calling a provided function on every element in the calling array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Fill in the blank: The _______ keyword is used to create a new object in JavaScript.

A

new

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What is the difference between ‘let’ and ‘var’?

A

‘let’ is block-scoped, while ‘var’ is function-scoped.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

What is a callback function?

A

A callback function is a function passed into another function as an argument to be executed later.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

What is the purpose of the ‘filter()’ method?

A

The ‘filter()’ method creates a new array with all elements that pass the test implemented by the provided function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

True or False: JavaScript has a built-in type for dates.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

What is the ‘typeof’ operator used for?

A

The ‘typeof’ operator is used to determine the data type of a variable.

29
Q

What does the ‘reduce()’ method do?

A

The ‘reduce()’ method executes a reducer function on each element of the array, resulting in a single output value.

30
Q

What is the purpose of the ‘setTimeout()’ function?

A

The ‘setTimeout()’ function calls a function or evaluates an expression after a specified number of milliseconds.

31
Q

Fill in the blank: JavaScript uses _______ to manage asynchronous code execution.

A

Event loop

32
Q

What is a module in JavaScript?

A

A module is a self-contained piece of code that can be reused and imported/exported in different parts of an application.

33
Q

What are template literals in JavaScript?

A

Template literals are string literals that allow embedded expressions, enclosed by backticks (`).

34
Q

True or False: JavaScript can manipulate the HTML and CSS of a web page.

A

True

35
Q

What is the ‘window’ object?

A

The ‘window’ object represents the browser window and is the global object in a web environment.

36
Q

What does ‘NaN’ stand for in JavaScript?

A

NaN stands for ‘Not-a-Number’.

37
Q

What is the purpose of the ‘splice()’ method?

A

The ‘splice()’ method changes the contents of an array by removing or replacing existing elements and/or adding new elements.

38
Q

What is an IIFE?

A

An IIFE is an Immediately Invoked Function Expression that runs as soon as it is defined.

39
Q

What does ‘JSON.stringify()’ do?

A

The ‘JSON.stringify()’ method converts a JavaScript object or value to a JSON string.

40
Q

Fill in the blank: JavaScript uses _______ to handle errors.

A

Exceptions

41
Q

What is the purpose of the ‘async’ keyword?

A

The ‘async’ keyword is used to declare an asynchronous function that returns a promise.

42
Q

What is the purpose of the ‘await’ keyword?

A

The ‘await’ keyword is used to pause the execution of an async function until a promise is resolved.

43
Q

True or False: JavaScript supports inheritance.

A

True

44
Q

What is the ‘Array.isArray()’ method used for?

A

The ‘Array.isArray()’ method determines whether the passed value is an Array.

45
Q

What does the ‘Math.random()’ function do?

A

The ‘Math.random()’ function returns a floating-point, pseudo-random number between 0 (inclusive) and 1 (exclusive).

46
Q

What is the purpose of the ‘forEach()’ method?

A

The ‘forEach()’ method executes a provided function once for each array element.

47
Q

What is a ‘Promise.all()’ method used for?

A

‘Promise.all()’ returns a single Promise that resolves when all of the promises in the iterable have resolved.

48
Q

What does the ‘slice()’ method do?

A

The ‘slice()’ method returns a shallow copy of a portion of an array into a new array object.

49
Q

What is the purpose of the ‘Object.keys()’ method?

A

The ‘Object.keys()’ method returns an array of a given object’s own property names.

50
Q

What is the ‘localStorage’ object?

A

‘localStorage’ is a Web Storage API that allows you to store data in the browser persistently.

51
Q

Fill in the blank: The _______ method removes the last element from an array.

A

pop

52
Q

What is the difference between ‘undefined’ and ‘null’?

A

‘undefined’ means a variable has been declared but not assigned a value, while ‘null’ is an assignment value that represents no value.

53
Q

What is the ‘fetch()’ API used for?

A

The ‘fetch()’ API is used to make network requests and handle responses in a promise-based manner.

54
Q

What does the ‘spread’ operator do?

A

The spread operator allows an iterable (like an array) to be expanded in places where zero or more arguments or elements are expected.

55
Q

What is the difference between a ‘function declaration’ and a ‘function expression’?

A

A function declaration defines a named function that can be called before it’s defined, while a function expression creates a function that can only be called after it’s defined.

56
Q

What does ‘Math.floor()’ do?

A

The ‘Math.floor()’ function returns the largest integer less than or equal to a given number.

57
Q

What is the ‘setInterval()’ function used for?

A

The ‘setInterval()’ function repeatedly calls a function with a fixed time delay between each call.

58
Q

True or False: JavaScript can be used on the server-side.

A

True

59
Q

What is the purpose of the ‘bind()’ method?

A

The ‘bind()’ method creates a new function that, when called, has its ‘this’ keyword set to the provided value.

60
Q

What is the ‘slice()’ method?

A

The ‘slice()’ method returns a shallow copy of a portion of an array into a new array object.

61
Q

What is a ‘symbol’ in JavaScript?

A

A symbol is a unique and immutable primitive value that can be used as the key of an object property.

62
Q

What is the ‘reduceRight()’ method?

A

The ‘reduceRight()’ method executes a reducer function on each element of the array, from right to left.

63
Q

What does ‘Object.assign()’ do?

A

‘Object.assign()’ copies all enumerable own properties from one or more source objects to a target object.

64
Q

What is a ‘getter’ in JavaScript?

A

A getter is a special method that gets the value of a specific property in an object.

65
Q

What is a ‘setter’ in JavaScript?

A

A setter is a special method that sets the value of a specific property in an object.

66
Q

What does ‘Object.freeze()’ do?

A

‘Object.freeze()’ prevents new properties from being added to an object and marks all existing properties as read-only.

67
Q

What is a ‘prototype’ in JavaScript?

A

A prototype is an object from which other objects inherit properties.

68
Q

What is the ‘instanceof’ operator used for?

A

The ‘instanceof’ operator tests whether an object is an instance of a specific constructor.

69
Q

What is the ‘length’ property of an array?

A

The ‘length’ property of an array returns the number of elements in that array.