Skip to content

Instantly share code, notes, and snippets.

@femontanha
Created July 16, 2013 21:43
Show Gist options
  • Save femontanha/6015424 to your computer and use it in GitHub Desktop.
Save femontanha/6015424 to your computer and use it in GitHub Desktop.
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
<!-- content to be placed inside <body>…</body> -->
var myObj = function( name, lastName ) {
this.name = name;
this.lastName = lastName;
return this;
};
myObj.prototype.getName = function() {
return this.name;
};
myObj.prototype.getLastName = function() {
return this.lastName;
};
myObj.prototype.getFullName = function() {
return this.name + ' ' + this.lastName;
};
//console.log( myObj() === window );
//console.log( typeof myObj );
//console.log( myObj.length );
//console.log( myObj instanceof Function );
//console.log( myObj === Function);
//console.log( myObj.__proto__ === Function.prototype);
var myInst = new myObj( 'fellipe', 'azambuja' );
//console.log( myInst.getName() );
//console.log( myInst.getLastName() );
//console.log( myInst.getFullName() );
//console.log( myObj.prototype );
// define the game object constructor
var GameObject = function( width, height ) {
this.x = Math.floor( (Math.random() * myCanvasWidth) + 1 );
this.y = Math.floor( (Math.random() * myCanvasHeight) + 1 );
this.width = width;
this.height = height;
return this;
};
// (re)define the game prototype object
GameObject.prototype = {
x: 0,
y: 0,
width: 5,
height: 5,
draw = function() {
myCanvasContext.fillRect(this.x, this.y, this.width. this.height)
}
};
{"view":"separate","fontsize":"100","seethrough":"","prefixfree":"1","page":"javascript"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment