I have an array which is made up of players. It is defined like so:
console.log gives me this:
Which makes sense and is what I want.
The function is ran again and hits this line:
But to check if event_id itself needs initializing, I do the following:
This is equivalent to:
Which I have been advised never to use because falsey and undefined are different things.
Now with console.log I still get this:
event_id is still 1. BUT, when I expand this line in the console, I get this:
event_id there is clearly 5. When I unexpand I get the line above where event_id is 1!
In a later function I set my event id like so:
$players['' + username + '']['event_id'] = Number($gameMap._lastSpawnEventId);
When I console.log $players['' + username + '']['event_id'] I get 5.
Now when I run the original function, the same log returns 1.
Can anyone make sense of this (or am I in fact creating a mess)?
$players['' + username + ''] = { 'username': username, 'x': x, 'y': y, 'dir': dir, 'skin': skin, 'hair': hair, 'colour': colour, 'clothes': clothes, 'event_id': event_id };
console.log gives me this:
Which makes sense and is what I want.
The function is ran again and hits this line:
$players['' + username + ''] = { 'username': username, 'x': x, 'y': y, 'dir': dir, 'skin': skin, 'hair': hair, 'colour': colour, 'clothes': clothes, 'event_id': event_id };
But to check if event_id itself needs initializing, I do the following:
if ($players['' + username + ''] === undefined)
{
event_id = 1;
}
else
{
event_id = $players['' + username + '']['event_id'];
}
This is equivalent to:
value = value || 0;
Which I have been advised never to use because falsey and undefined are different things.
Now with console.log I still get this:
event_id is still 1. BUT, when I expand this line in the console, I get this:
event_id there is clearly 5. When I unexpand I get the line above where event_id is 1!
In a later function I set my event id like so:
$players['' + username + '']['event_id'] = Number($gameMap._lastSpawnEventId);
When I console.log $players['' + username + '']['event_id'] I get 5.
Now when I run the original function, the same log returns 1.
Can anyone make sense of this (or am I in fact creating a mess)?