Jump to content

What is the purpose of a 'name :' label ?


vmars316
 Share

Recommended Posts

Hello & Thanks ,

I am making my way thru game tutorial -

http://www.w3schools.com/games/tryit.asp?filename=trygame_controllers_keys

and I would like to know , what is the purpose of a 'name :' label ( canvas : , start : , clear : ) ?

var myGameArea = {
    canvas : document.createElement("canvas"),
    start : function() {
        this.canvas.width = 480;
        this.canvas.height = 270;
        this.context = this.canvas.getContext("2d");
        document.body.insertBefore(this.canvas, document.body.childNodes[0]);
        this.interval = setInterval(updateGameArea, 20);
        window.addEventListener('keydown', function (e) {
            myGameArea.key = e.keyCode;
        })
        window.addEventListener('keyup', function (e) {
            myGameArea.key = false;
        })
    }, 
    clear : function(){
        this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
    }

Also , for ' ("canvas"), ' , why the comma ' , ' ?

 

Thanks

 

 

Link to comment
Share on other sites

Ok , I see , those are just properties , just a more complex version of below:

var person = {
    firstName: "John",
    lastName : "Doe",
    id       :  5566
};

While I've got ya on the phone , let me ask :

window.addEventListener('keydown', function (e) {
            myGameArea.key = e.keyCode;
        }

is ' e ' a reserved word ?

Also

myGamePiece = new component(30, 30, "red", 10, 120);

is 'component' a reserved word ?

 

Pls , where can I find a list of all js reserved word ?

 

Thanks again..

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...