This statement only returns true, if x1 equals 10:
This statement always returns true, because the assignment is always true:
Addition is about adding numbers.
Concatenation is about adding strings.
Because of this, when adding a number as a number, will produce a different result from adding a number as a string:
When adding two variables, it can be difficult to anticipate the result:
But, breaking a statement in the middle of a string will not work:
You must use a "backslash" if you must break a statement in a string:
Because of a misplaced semicolon, this code block will execute regardless of the value of x:
Because of this, these two examples will return the same result:
Because of this, example 3 will also return the same result:
But, what will happen if you break the return statement in two lines like this:
The function will return undefined!
If a statement is incomplete like:
But since this statement is complete:
|Never break a return statement.|
Many programming languages support arrays with named indexes.
Arrays with named indexes are called associative arrays (or hashes).
After the automatic redefinition, array methods and properties will produce undefined or incorrect results:
To be null, an object has to be defined, otherwise it will be undefined.
If you want to test if an object exists, this will throw an error if the object is undefined:
Because of this, you must test typeof() first: