Javascript Flashcards

1
Q

loop through and object with for…each

A

for each(var in obj){}

ps: for each is obsolete, for(var of obj) is preferred, but Array.prototype.forEach() is still used.

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

one difference between for() and Array.prototype.forEach()

A

you can break; in the middle of a for loop;
forEach spares you of writting the iteration conditions, making it less error prone;
forEach has more readability

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

JSON.parse vs JSON.stringify

A

JSON.parse: converts a json file into a js object

JSON.stringify: get a JS object and converts into string format.

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

getting the directory name instead of the file name in:

C:\User\Desktop\Folder\file.js

A

path.dirname(‘path’);

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

Calling multiple promisses with one function

A

Promisse.all([func1, func2, func3. …]).then()

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