This file contains hidden or 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 DI = function(){ | |
var throwDelayedError = function(typeOfErr, err){ | |
setTimeout(function(){ | |
throw typeOfErr + ': ' + err; | |
}, 0); | |
}; | |
var injectables = {}; |
This file contains hidden or 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 arrayBuilder = function(){ | |
return { | |
arr: [], | |
addElem: function(element){ | |
this.arr.push(element); | |
}, | |
getArray: function(){ | |
var c = this.arr; | |
this.clearArray(); |
This file contains hidden or 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 httpGet(theUrl, callback, callbackContext, errorCallback) { | |
var req = new XMLHttpRequest(); | |
req.open("GET", theUrl, true); | |
req.onreadystatechange = (function(){ | |
if (req.readyState == 4 && (req.status >= 200 && req.status < 300)){ | |
callback.call(callbackContext); | |
} else if (req.readyState == 4) { | |
errorCallback(); | |
} | |
}); |
This file contains hidden or 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 tester(func) { | |
console.log(func([],[]), 'should be []'); | |
console.log(func([1,2],[1,2]), 'should be [1,1,2,2]'); | |
console.log(func([1,2],[1]), 'should be [1,1,2]'); | |
console.log(func(['hi'],[undefined, 'lo']), 'should be [hi,undefined, lo]'); | |
console.log(func([2,3],[]), 'should be [2,3]'); | |
console.log(func([],[2,'und', 5]), 'should be [2,und,3]'); | |
})(function concat(arr1, arr2){ | |
var catted = []; | |
var iter = 0; |
This file contains hidden or 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 withFor(list) { | |
var sum = 0; | |
list.forEach( function(item) { | |
if (typeof item === 'number') { | |
sum += item; | |
} | |
}); | |
return sum | |
}; |
NewerOlder