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();
@gordonmzhu
gordonmzhu / librarySystem.js
Last active December 20, 2016 20:46
Simple Library Loader
// (function() {
// var libraryStorage = {};
// function librarySystem(libraryName, callback) {
// if (arguments.length > 1) {
// libraryStorage[libraryName] = callback();
// } else {
// return libraryStorage[libraryName];
// }
// }
<!doctype html>
<html lang="en" ng-app="app">
<head>
<meta charset="utf-8">
<title>Wait and Eat</title>
<!--Bootstrap latest compiled and minified CSS-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<!--Optional theme-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
</head>
function runWithDebugger(callback){
debugger;
callback.apply(null, arguments[1]);
}
1. Read the answer and try to figure out what it does. Write it out on paper. Add notes, annotate it.
2. Run the code, see how it works, what arguments it takes, edge cases, etc.
3. Run it through the debugger, Use different arguments to test different scenarios.
4. Try replicating the function by writing out single statements in the console.
5. Be able to write the entire function on your own without looking at the solution. Could include mock interviews.
function returnFive() {
var number = 5;
return number;
}
function returnNothing() {
var number = 5;
}
var five = returnFive();
function outer(usedInsideInner) {
return function() {
console.log(usedInsideInner);
}
}
var inner = outer(5);
inner(); // should log 5
To join the video chat, click the big "Call in" button (limited to 4 people).
Ask questions in the live chat on the right.
@gordonmzhu
gordonmzhu / app.module.js
Last active February 17, 2016 20:47
Using angular.run to see if a module loads
(function() {
'use strict';
angular
.module('app', []);
.run(function() {
console.log('did this file run?');
})
})();