//Create instance of box class
var myBox = new Box(100,200);
console.log("Box width: " + myBox.Width);
console.log("Box width: " + myBox.Height);
//Change box size with function
myBox.changeSize(500,500);
//Change box size with variables
myBox.Width = 500;
myBox.Height = 500;
//Box class
function Box(width, height) {
//Class variables
this.Width = width;
this.Height = height;
//Class functions
this.SomeFunction = function() {
}
this.changeSize = function(w,h) {
this.Width = w;
this.Height = h;
}
}
Comments