I'm following melon js tutorial. This is at the top of my HUD.js file.
game.HUD = game.HUD || {}
I've seen this before in other examples. What does the namespace.something = namespace.something || {}
syntax mean and why is it needed?
I'm following melon js tutorial. This is at the top of my HUD.js file.
game.HUD = game.HUD || {}
I've seen this before in other examples. What does the namespace.something = namespace.something || {}
syntax mean and why is it needed?
Copyright © 2021 Jogjafile Inc.
||
is a null coalesce operator so you are saying in that line return my object if it already exists or a new object if it does not (is null)