Skip to content

Instantly share code, notes, and snippets.

@matiasherranz
Created December 11, 2015 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matiasherranz/1621d680f878d11199c7 to your computer and use it in GitHub Desktop.
Save matiasherranz/1621d680f878d11199c7 to your computer and use it in GitHub Desktop.
http://collabedit.com/n38gj -- playing with js.js
function Car() {
}
Car.protoype = {
}
// can i make it singleton
for (var i=1; i<=5; i++) {
setTimeout( function timer(){
console.log( i );
}, i*1000 );
}
for (var i=1; i<=5; i++) {
(function(){
setTimeout( function timer(){
console.log(i);
}, x*1000 );
})();
}
for (var i=1; i<=5; i++) {
setTimeout( function timer(i){
console.log( i );
}.bind(this, i), i*1000 );
}
for (var i=1; i<=5; i++) {
setTimeout( function timer(t){
console.log( t );
}, i*1000, i );
}
$("#someid") $("[id^=someid]") $('.someclass')
<script>
$('li').onclick(function(e){
$('div').html('you clicked ' + $(this).html());
})
</script>
<ul>
<li> blah</li>
<li> blah2</li>
</ul>
<div>
you clicked blah
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment