Skip to content

Instantly share code, notes, and snippets.

@NoMan2000
Created June 12, 2014 02:56
Show Gist options
  • Save NoMan2000/db16781ddd5b37db2082 to your computer and use it in GitHub Desktop.
Save NoMan2000/db16781ddd5b37db2082 to your computer and use it in GitHub Desktop.
Infinite add Object
myObject = {
callFunction : function(){
alert("Hello there");
},
name : "Ryan",
add : function(){
var args = arguments;
var a = 0;
for(var i=1; i<args.length; i++){
a += (parseInt(args[i-1], 10) + parseInt(args[i], 10));
console.log(a);
}
return alert(a);
},
nestedObject : {
name : 'nested object',
callFunction : function(){
alert("Called from within a function");
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment