Syntax & Operators Flashcards

1
Q

What is the value of ‘this’ in an event handler?

A

The instance of the HTML element with the event handler

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

In an object literal, what does ‘this’ refer to?

A

The object itself

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

What happens if you forget a break statement?

A

Execution falls through to the next case statement

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

What does the spread operator do?

A
  • Expands an iterable object such as a string or array into another array.
  • Can be used to pass multiple arguments into a method
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the syntax for the spread operator?

A

(…) immediately preceding an expression (on the right hand side)

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

How do you define a label in JavaScript?

A

On a separate line create a name followed by a colon

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

What is the value of result in the following statement?

let result = 10;

result += 5;

A

15

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

What error type is thrown if you have an error in the eval() function?

A

SyntaxError

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

Which object data types should you avoid?

A

Date, Number, String

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

What is the value of ‘this’ in the call or apply method?

A

A reference to the object passed to call or apply

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

What is the value of ‘this’ in a constructor function?

A

The object itself

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

What does the continue statement do?

A

Goes back to the top of a loop and continues with next iteration

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

When ++ or – is placed after a variable, what happens?

A

The current value of the variable is used, then incremented/decremented (respectively)

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

What is the correct syntax for use strict?

A

‘use strict’;

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

What is passed to the catch block?

A

An error object

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

What two properties must be in a custom error object?

A

name and message

17
Q

What object do all other object data types inherit from?

A

Object

18
Q

What does the instanceof operator do?

A

Tests to see if an object inherits from Object

19
Q

When ++ o r – is placed before a variable, what happens?

A

The current value of the variable is incremented/decremented (respectively) and then used,

20
Q

What is used strict used for?

A
  • It forces all variables to be declared before they are used.
  • Cannot use reserved words as variables.
  • Can not delete a variable.
  • Can not delete a function.