Skip to content

Instantly share code, notes, and snippets.

View gordonmzhu's full-sized avatar

Gordon Zhu gordonmzhu

View GitHub Profile
// VIDEO REMAINING INTERNAL HELPER METHODS
// QUESTIONS AND OBSERVATIONS
//QUESTION 1: why object[key] == null and not object[key] === undefined ? Why its compare it with null instead of undefined. Because if an object property is missing obj['prop'] it will return undefined not null.
// QUESTION 2: object[key] = defs[key]; if defaultObject has an array as property with couple of values instead of primitive values then it will copy to the new return object that array by reference and if you change a value to one it will change to all.
var defaultCar = {
color: ['grey', 'red'],
wheels: 4,
@gordonmzhu
gordonmzhu / libSys.js
Last active February 7, 2017 03:01 — forked from michael-mafi/libSys.js
library loading system
var libs = {};
function librarySystem(libName, depArr, cb){
if (arguments.length > 1 && depArr.length >= 1){
var storArr = [];
for(var i = 0; i < depArr.length; i++){
storArr.push(libs[depArr[i]]);
}
libs[libName] = cb.apply(this, storArr);
} else {
libs[libName] = cb();