Created
June 12, 2014 02:56
-
-
Save NoMan2000/db16781ddd5b37db2082 to your computer and use it in GitHub Desktop.
Infinite add Object
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
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