The right code for a script call

Hi! Programming for me is like some alien language so I need some help with script calls.
I want to create a common event that will check if an event with id "1" is close to the player (it's a common event because I need to check this on several maps). I've found two versions of a script call that are a little different (it goes into conditional branch -- script):
1. Math.abs($gamePlayer.x - $gameMap._events[1]._x) + Math.abs($gamePlayer.y-$gameMap._events[1]._y) <= 3;
2. Math.abs($gameMap.event(1).x - $gamePlayer.x) + Math.abs($gameMap.event(1).y - $gamePlayer.y) <= 3
Which one is the correct one for a common event? And what is the difference between $gameMap.event(1).y and $gameMap._events[1]._y ??
To keep it simple, both should work.
"$gameMap.event(1)" and "$gameMap._events[1]" are basically refering to the same data.

I've moved this thread to Javascript Support. Thank you.

To keep it simple, both should work.
"$gameMap.event(1)" and "$gameMap._events[1]" are basically refering to the same data.
Thank you!
I realise this is resolved, but to explain a little (since it's been put in Learning JavaScript)...

$gameMap is a Game_Map object. Among other things, this type of object has a list of events present on the map and a "getter" function for getting a value from this list. The former is called the _events property and the latter is the event function. Both belong to the Game_Map object, and since the event function refers directly to the relevant item in _events, they work exactly the same (like @TWings said). Similarly for _x & _y (actual values) vs x & y (getters/setters). =)

It is good practice to use getter/accessor methods like event(id) where possible, since they can help prevent you from (accidentally) changing the value of an object. They do have other uses (e.g. do something whenever the value is checked and/or set) but I don't think MV makes much use of that. 😴

Original thread: https://forums.rpgmakerweb.com/threads/the-right-code-for-a-script-call.94223/