Skip to content

Instantly share code, notes, and snippets.

@ScottDalessandro
Created August 17, 2016 00:58
Show Gist options
  • Select an option

  • Save ScottDalessandro/03cf52d5dc17aaf10fad71b5dff1567f to your computer and use it in GitHub Desktop.

Select an option

Save ScottDalessandro/03cf52d5dc17aaf10fad71b5dff1567f to your computer and use it in GitHub Desktop.
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