Javascript Flashcards
loop through and object with for…each
for each(var in obj){}
ps: for each is obsolete, for(var of obj) is preferred, but Array.prototype.forEach() is still used.
one difference between for() and Array.prototype.forEach()
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
JSON.parse vs JSON.stringify
JSON.parse: converts a json file into a js object
JSON.stringify: get a JS object and converts into string format.
getting the directory name instead of the file name in:
C:\User\Desktop\Folder\file.js
path.dirname(‘path’);
Calling multiple promisses with one function
Promisse.all([func1, func2, func3. …]).then()