As a novice in JavaScript, I find myself struggling to fully grasp certain aspects of the script below;
I understand that Map, Player, and App are all classes, while map, player, and app represent instances of these classes;
However, why is the keyword "this" being used with the objects map and player instead of simply using var map = new Map()
and var player = new Player()
?
Any insights or guidance on this matter would be greatly appreciated!
var application;
var Application = function()
this.map = new Map();
this.player = new Player();
};
(function() {
application = new Application();
})();