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 quickSort(arr) { | |
var less = more = pivots = []; | |
if (arr.length > 1) { | |
pivot = arr[0]; | |
arr.forEach(function (i) { | |
if (i < pivot) { | |
less.push(i); | |
console.log(i) |
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
foo(); | |
var test; | |
function foo(){ | |
function bar() { | |
test = console.trace(); | |
} | |
bar(); | |
} |
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
// When your server receives a request on | |
// http://localhost:4000/set?somekey=somevalue | |
// it should store the passed key and value in memory. | |
// When it receives a request on | |
// http://localhost:4000/get?key=somekey | |
// it should return the value stored at somekey. | |
var express = require('express'); | |
var app = express(); | |
var server = require('http').createServer(app); |
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
var test = [1,2,3] | |
function check(arr){ | |
arr.forEach(function(el){ | |
if(el === 2){ | |
console.log('ouch') | |
return true; | |
} | |
}) | |
return false; |
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
// init renderer | |
var renderer = new THREE.WebGLRenderer({ | |
antialias : true, | |
}); | |
renderer.setClearColor(new THREE.Color('lightgrey'), 1) | |
renderer.setSize( window.innerWidth, window.innerHeight ); | |
document.body.appendChild( renderer.domElement ); | |
// init scene and camera | |
var scene = new THREE.Scene(); |
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
var nodes = [] | |
var colors = ['r', 'g', 'b', 'y'] | |
function Node(left, right, up, down, color) { | |
this.left = left | |
this.right = right | |
this.up = up | |
this.down = down | |
this.color = color | |
this.checked = false |
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 Car(name) { | |
this.name = name; | |
} | |
Car.prototype.display = function () { | |
console.log(this.name); | |
} | |
var benz = new Car('benz'); | |
benz.display(); // benz, this === benz |
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 bumang(i){ | |
return function(){ | |
console.log(i) | |
} | |
} | |
for(var i = 0; i< 10; i++){ | |
setTimeout( | |
bumang(i) | |
, i * 1000); |
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
this.x = 9; | |
var module = { | |
x: 81, | |
getX: function() { return this.x; } | |
}; | |
module.getX(); // 81 | |
var getX = module.getX; |
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
var animals = [ | |
{ species: 'Lion', name: 'King' }, | |
{ species: 'Whale', name: 'Fail' } | |
]; | |
for(var i = 0; i < animals.length; i++){ | |
(function(i){ | |
this.print = function(){ | |
console.log(i + ' ' + this.species + ' ' + this.name) |
OlderNewer