| 251 | * To test if a property or variable is undefined, use explicit type+value equality (`===`), instead of value equality (`==`) or `typeof()`: |
| 252 | {{{ |
| 253 | #!js |
| 254 | if (someObject.foo === undefined) |
| 255 | // foo is not defined |
| 256 | else |
| 257 | // foo is defined |
| 258 | }}} |
| 259 | * In general you don't want to explicitly check for `null` which has a distinct, often misunderstood, meaning from `undefined`. A few parts of the engine return a `null` object reference (for example, the component system when a component is not available for the specified entity, or the GUI when a requested object was not found), you can check for valid object references easily: |
| 260 | {{{ |
| 261 | #!js |
| 262 | if (!cmpFoo) |
| 263 | // Oh it's not a valid component, don't use it |
| 264 | else |
| 265 | // It is a valid component, we can use it |
| 266 | }}} |
| 267 | |