I'm very new in javascript. I play on codepen.io to learn some javascript project. I found Pong-JS implementation. I found something that i cant figure it out. Because i don't know what kind of thing it's
var Game = {
initialize: function () {
this.canvas = document.querySelector('canvas');
this.context = this.canvas.getContext('2d');
this.canvas.width = 1400;
this.canvas.height = 1000;
this.canvas.style.width = (this.canvas.width / 2) + 'px';
this.canvas.style.height = (this.canvas.height / 2) + 'px';
this.player = Paddle.new.call(this, 'left');
this.paddle = Paddle.new.call(this, 'right');
this.ball = Ball.new.call(this);
this.paddle.speed = 8;
this.running = this.over = false;
this.turn = this.paddle;
this.timer = this.round = 0;
this.color = '#2c3e50';
Pong.menu();
Pong.listen();
}, //there are another properties
My question why it use this.
to make some variable. Why not use var
? Because i find out about this.
syntax and i can't relate those explanation.
I hope you can help me understand this line of code.
here is the codepen : https://codepen.io/gdube/pen/JybxxZ?editors=1010