This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
let action = 'barks'; | |
let foo = function() { | |
console.log('foo', action); | |
}; | |
})(); | |
console.log(typeof foo); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let Foo = function() { | |
this._name = 'Foo'; | |
}; | |
Foo.prototype.bark = function() { | |
console.log(this._name, ' barks'); | |
}; | |
let foo = new Foo(); | |
let fooBark = foo.bark; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://github.com/altercation/solarized/issues/146 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export PATH=$PATH:~/.bin:~/.nvm | |
export DOCKER_HOST=tcp://localhost:4243 | |
export PS1="\[\033[1;32m\]`hostname`\[\033[0m\] \[\033[1;35m\]\u\[\033[0m\]:\[\033[1;33m\]\w\[\033[0m\]$ " | |
export CLICOLOR=1 | |
export LSCOLORS=ExFxCxDxBxegedabagacad | |
export PATH=$PATH:/usr/local/share/gcutil | |
source ~/.nvm/nvm.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function procedure(instance, method, description) { | |
//console.log(description) | |
description.value.__procedure = true; | |
var org = description.value; | |
if (instance.__procedureDefined) { | |
throw new Error('Already has one procedure'); | |
} | |
instance.__procedureDefined = true; | |
description.value = function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Metric | Mean | Median | Min | Max | StdDev | 95% Bound | | |
| -------------------------- | ---- | ------ | ---- | ---- | ------ | --------- | | |
| firstTabAppearing | 0 | 0 | 0 | 0 | 0 | 0 | | |
| songsTabSwitching-cold | 23 | 23 | 23 | 23 | 0 | 23 | | |
| songsTabAppearing-cold | 953 | 953 | 953 | 953 | 0 | 953 | | |
| albumsTabSwitching-cold | 991 | 991 | 991 | 991 | 0 | 991 | | |
| albumsTabAppearing-cold | 1863 | 1863 | 1863 | 1863 | 0 | 1863 | | |
| artistsTabSwitching-cold | 1909 | 1909 | 1909 | 1909 | 0 | 1909 | | |
| artistsTabAppearing-cold | 2899 | 2899 | 2899 | 2899 | 0 | 2899 | | |
| playlistsTabSwitching-cold | 2935 | 2935 | 2935 | 2935 | 0 | 2935 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function f(e) { | |
var p = new Promise((r) => { | |
setTimeout(() => {r(e)}, 1000); | |
}) | |
return p; | |
} | |
function* makeSimpleGenerator(array){ | |
var nextIndex = 0; | |
while(nextIndex < array.length){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TodoListManager.prototype.onItemChecked = function(event) { | |
// Do something when the Todo item is clicked. | |
var checked = event.target.classList.contains('checked'); | |
var todoId = Number.parseInt(event.target.dataset.todoId, 10); | |
this._listTodoItem[todoId].checked = checked; | |
}; | |
TodoListManager.prototype.start = function() { | |
window.addEventListener('click', this.onItemChecked) | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var someArray = [1, 2, 3]; | |
var body = document.querySelector('body'); | |
body.addEventListener('click', function() { | |
// Note: 'someArray' is neither an parameter nor a global variable. | |
// Will print '1,2,3' in console when clicking. | |
console.log(someArray.join(',')); | |
// And since this function will be triggered later, | |
// you can see closure is accross the time & space (LOL) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// "pure" version | |
[1, 2, 3, 4].reduce(function(acc, elem) { | |
var result = []; | |
// Generate multiple "elements". | |
for (var i = 0; i < elem; i++) { | |
result.push(i); | |
} | |
// And generate the new "array" as the new accumulator. | |
return acc.concat(result); | |
}, []) |