Skip to content

Instantly share code, notes, and snippets.

@BigaDev
Last active August 29, 2015 14:14
Show Gist options
  • Save BigaDev/4be07163f23fc1ad9509 to your computer and use it in GitHub Desktop.
Save BigaDev/4be07163f23fc1ad9509 to your computer and use it in GitHub Desktop.
Today I learn
## The --depth=14 option just tells Git to pull down only the last 14 commits. This makes the download much smaller and faster.
git clone --depth=14 https://github.com/xxx/xxx
## typeof method in javascript
typeof 1; // number
typeof "1"; // string
typeof null; // object
typeof undefined; // undefined
typeof this; // object
typeof typeof // Unexpected end of input
## Closures: is a special kind of object that combines two things: a function, and the environment in which that function was
created. The environment consists of any local variables that were in-scope at the time that the closure was created.
var add = (function() {
var num =0;
function count(){
num += 1;
return num;
}
return count;
})();
add(); // 1
add(); // 2
## Memoization: keep previous results to reduce the amount of work for function such as Fibonacci
var fibonacci = (function() {
var memo = {};
function f(n) {
var value;
if (n in memo) {
value = memo[n];
} else {
if (n === 0 || n === 1)
value = n;
else
value = f(n - 1) + f(n - 2);
memo[n] = value;
}
return value;
}
return f;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment