I want to do something that is applicable in Java Please:
var hat = New Hat (Hat.Color.RED, Hat.Size.MEDIUM); How can I do this (tried to mess with the function prototype , but with little success)? Hat will be a constructor function:
function Hat (color, size) {this .id = "X" + color + size; // or something else} on the prototype hat are examples for "methods": Hat.prototype.raise = Function () {...}; But the properties of the constants function object are:
Hat.Color = {RED: "F00", GREEN: "0F0", .. ..} ; Hat.Size = {Medium: 0, Big: 1, ...}; If your library correctly executes the "extension" function (nothing special on constructors), then it should also work:
Object.extend (hat, {color: {Red: "F00", Green: "0f0", ...}, Size: = {Medium: 0, Big: 1, ...},});
Comments
Post a Comment