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 start = new Date(); | |
// ---- | |
var size = 10000; | |
var a = []; | |
for (var i = 0; i < size; i++) { | |
a.push(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
var newFile = function() { | |
var state = newState(); | |
function close() {//maybe state.close = function() instead | |
if (state.already()) { log('already closed'); return; } | |
}; | |
state.pulse = 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
// Calculate the average of a number of values as they are produced | |
var newAverage = function() { | |
var o = {}; | |
var n = 0; o.n = function() { return n; } // How many values we have, 0 before you add one | |
var total = 0; o.total = function() { return total; } // The total sum of all the given values | |
var minimum = 0; o.minimum = function() { return minimum; } // The smallest value we have seen, 0 before we have any values | |
var maximum = 0; o.maximum = function() { return maximum; } // The largest value we have seen, 0 before we have any values | |
var recent = 0; o.recent = function() { return recent; } // The most recent value you added, 0 before we have any values |
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 makePerson = function (name, age) { | |
var me = {}, my = {}; | |
//members | |
my.name = name; | |
my.age = age; | |
//private methods |
NewerOlder