I ran into JavaScript code I want to use, and I don't understand some parts of it.
I use the PyCharm environment to edit it. The source of the code is the following: https://github.com/ErmiyaEskandary/Slither.io-bot
For example, in this part of the code:
var canvasUtil = window.canvasUtil = (function() {
return {
// Ratio of screen size divided by canvas size.
canvasRatio: {
x: window.mc.width / window.ww,
y: window.mc.height / window.hh
},
// Set direction of snake towards the virtual mouse coordinates
setMouseCoordinates: function(point) {
window.xm = point.x;
window.ym = point.y;
},
I don't understand what the "window" object is, and where it's defined. When I tried to find its definition, I got to a file named DHTML.js, where the only definition for window there was:
/**
@type {Window}
*/
Window.prototype.window = 0;
or
/**
@type {Window}
@const
*/
window = 0;
(This file is not a part of the repository.)
What is this window object? How does it work? And where can I find more information about it?
In the code - what does window.mc, for example, mean? I didn't found any information about the window's property. There are similar objects in the code like window, but this one appears the most.
(I tried to look it up but the information I found in W3Schools doesn't seems to be related: The Window Object)