I know a little bit about Javascript, but am still finding my way. I saw a tutorial on Javascript working with Socket.IO. I was trying to follow along, but was a little confused by this Javascript constructor, with header Online code. I have not seen this format before. Is this equivalent to the code I wrote below it? Is it proper to create a constructor with the var self = {...} method?
//Online code
//-------------------------
var Player = function(id){
var self = {
x:250,
y:250,
id:id
}
return self;
}
//Equivalent?
//------------------------
var Player = function(id){
var self = this;
this.x = 250;
this.y = 250;
this.id = id;
}