Created
August 17, 2016 00:58
-
-
Save ScottDalessandro/03cf52d5dc17aaf10fad71b5dff1567f to your computer and use it in GitHub Desktop.
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 setPropertiesOnObjLiteral(obj) { | |
| obj["x"] = 7; | |
| obj["y"] = 8; | |
| obj["onePlus"] = function(num) { | |
| return num + 1; | |
| } | |
| } | |
| function setPropertiesOnArrayObj(arrayObject) { | |
| arrayObject['hello'] = function() { | |
| return "Hello!" | |
| }; | |
| arrayObject['full'] = 'stack'; | |
| arrayObject[0] = 5; | |
| arrayObject['twoTimes'] = function(num) { | |
| return num *2; | |
| }; | |
| } | |
| function setPropertiesOnFunctionObj(funcObj) { | |
| funcObj.year = 2015; | |
| funcObj.divideByTwo = function(num) { | |
| return num/2; | |
| } | |
| funcObj.prototype.helloWorld = function() { | |
| return "Hello World"; | |
| } | |
| return "I am a function object, all functions are objects! Function can have their own properties too!" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment