javascript - Uncaught SyntaxError: Unexpected token = in Chrome -
i following on-line tutorial create simple game in html using canvas , javascript. tried load seemed fine code nothing showing on screen , received error in console saying
uncaught syntaxerror: unexpected token =
this portion of code seems incorrect:
player = { x: null, y: null, width: 20, height: 100, update = function() {}, draw = function() { ctx.fillrect(this.x, this.y, this.width, this.height) }; };
ps - error showing in chrome.
you using =
signs in literal object definition, replace them :
update : function() {}, draw : function() { ctx.fillrect(this.x, this.y, this.width, this.height); }
as amtd specified in answer, error show after draw
definition, because putting ;
illegal token inside literal object definition
Comments
Post a Comment