JavaScript Flashcards

(26 cards)

1
Q

Name all the truthy values in javascript.

A
  • {}
  • []
  • 42
  • “false”
  • new Date(),
  • -42
  • 3.14
  • -3.14
  • Infinity
  • -Infinity
  • all objects
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Name all the falsy values in javascript.

A
  • false (boolean)
  • 0
  • -0
  • 0n
  • ””
  • null
  • undefined
  • NaN
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

in a method, what does this refer to?

A

the owner object

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

in strict mode, what does this refer to?

A

undefined

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

What’s an expression in Javascript?

A

any line of code that resolves to a value.
(can still resolve to null or undefined)

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

What’s a statement in Javascript?

A

performs an action. Doesn’t necessarily return a value.

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

What is Object restructuring ?

A

allows you to extract properties from an object into individual variables

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

What does a Spread operator do?

A

allows an iterable such as an array or string to be expanded in places where zero or more arguments or elements are expected.

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

Describe strict mode.

A

Helps eliminate some silent errors by changing them into throw errors

In strict mode, this is undefined in functions that are not methods or constructors.

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

What is the global object?

A

the default container that holds functions, variables and built in objects ( Math, Date, console etc.)

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

What is the owner object?

A

the object the method belongs to.

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

Are functions objects?

A

Yes.

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

In an array what does push() do?

A

add new elements(multiple) to the end of array + returns it.

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

In an array what does pop() do?

A

Removes the last element (one at a time) from an array, and returns it.

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

In an array what does shift() do?

A

Removes the first element from an array, and returns that. (one at a time)

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

In an array what does unshift() do?

A

Adds new elements to the beginning of an array, and returns
the new length.

17
Q

In an array what does slice() do?

A

Returns a shallow copy of a portion of an array.

18
Q

In an array what does splice() do?

A

Changes the contents of an array by removing or replacing
existing elements and/or adding new elements.

19
Q

In an array what does concat() do?

A

Used to merge two or more arrays, and returns a new array.

20
Q

What is an object?

A

A JavaScript object is a collection of properties where each property is an association between a key and a value.

21
Q

What is an object literal?

A

a list of zero or more pairs of property names and
associated values of an object, enclosed in curly braces ({}).

22
Q

What’s the first line of an object constructor?

A

let object_name = new Object();

23
Q

What does Object.keys() do?

A

returns an array of all the object’s keys.

24
Q

What does Object.entries() do?

A

returns an array of all the object’s key/value pairs

aka all keys and all values.

25
What does `Object.assign()` do?
copy original object’s properties to new `copy_object,` returns `copy_object.`
26
What does the rest parameter do?
allows a function to accept any number of arguments as an array.