for...in: Iterate over property name, in arbitrary order (because property doesn't have order)
for (let prop in obj) {// Check, in case prototype has customized propertiesif (obj.hasOwnProperty(prop) {// ... }}// when using in array, it iterates on index// Don't use thisfor (let index in arr) {}// use Object.keysObject.keys(obj).forEach(function (key, index) {console.log(obj[key]);}// underscore_.each(obj,function (value, key) {});
ES6: Iterate over values: for .. of
for (let value of arr) {}// use forEacharr.forEach(function (element, index) {console.log(element); });// underscore_.each(arr,function (element, index) {});
CommonJS Modules: The dominant implementation of this standard is in Node.js (Node.js modules have a few features that go beyond CommonJS). Characteristics:
Compact syntax
Designed for synchronous loading
Main use: server
Asynchronous Module Definition (AMD): The most popular implementation of this standard is RequireJS. Characteristics:
Slightly more complicated syntax, enabling AMD to work without eval() (or a compilation step).