Javascript Flashcards

1
Q

Difference between var and let

A

var is not scope attached, let is scope attached

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

Does Javascript supports autoconversion?

A

Yes

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

“This” in a method

A

Refers to the owner scope, or to the global scope

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

Style from HTML

A

document.getElementById(“id”).style.fontSize

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

Class from HTML

A

document.getElementById(“id”).className

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

“This” alone

A

Refers to the global scope

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

“This” in an event

A

Refers to the element that receives the event

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

setTimeout()

A

Receives function and delay in miliseconds. Call function after delay.

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

setInterval()

A

Receives function and delay in ms. Repeat function in the said delay time.

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

clearInterval()

A

Receives the id from the interval. Stops the interval.

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

What does sort() by default?

A

Sorts an array alphabetical and ascending.

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

How to sort numeric arrays?

A

(a, b) => a-b , this will sort ascending.

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

unshift()

A

Adds new elements to the beginning of an array. Overwites the original array. Returns the new lenght of the array.

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

push()

A

Adds new items to the end of an array.Overwites the original array. Returns the new lenght of the array.

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

shift()

A

Removes the first item of an array. Changes the original array. Returns the shifted element.

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

pop()

A

Removes the last element of an array.Changes the original array. Returns the popped element.

17
Q

delete array[0]

A

Delete values in the array leaving undefined values.

18
Q

concat()

A

Creates a new array by merging (concatenating) existing arrays. It does not change the existing arrays. It always returns a new array.

19
Q

flat()

A

Reduces the dimensionality of an array. Returns a new array.

20
Q

splice()

A

Receives position, elements to delete, and values to add. Add and remove elements from array. Chnage the original array, return an array from the deleted values.

21
Q

slice()

A

Receives start and end. Return a shallow copy of the array. Does not affect the orginal array.

22
Q

Shallow copy

A

Copy an object without appointing to the same memory at first level. But nested objects gonna be appointing to the same memory space.

23
Q

Object.assign()

A

It takes at least two objects and fusion them creating a shallow copy.

24
Q

Spread operator

A

{ …object, otherproperty: “” } creates a new shallow copy object fusioning the new properties with the introduced objects.

25
Q

Deep copy

A

creates an indepent space memory clone of the object

26
Q

How do you deep copy?

A

You can use JSON.parse to an stringify object, but functions and objects as properties will be affected. install lodash and use _.copyDeep() to a whole deep copy.

27
Q

reduce()

A

It is an iterator that receives a callback that sets accumulator and current value. It returns the final value of the accumulator.