View merge-arrays.js
for (var attrname in obj2) { obj1[attrname] = obj2[attrname]; }
// smashless version
/**
* Overwrites obj1's values with obj2's and adds obj2's if non existent in obj1
* @param obj1
* @param obj2
* @returns obj3 a new object based on obj1 and obj2
*/
function merge_options(obj1,obj2){
View generic-event-handler.js
function (ev) {
e = ev || window.event;
var target = e.target || e.srcElement;
// have fun here
// cancel bubbling?
e.cancelBubble = true;
if(e.stopPropagation) {
e.stopPropagation();
View fibonacci.js
function fib(n,undefined){
if(fib.cache[n] === undefined)
fib.cache[n] = fib(n-1) + fib(n-2);
return fib.cache[n];
}
fib.cache = [0,1,1];
fib(10);
console.log(fib.cache);