fbpx
Tricks

4 Secrets Of javaScript You Must Learn

1 Null is an Object

null is an empty or non-existent value.null must be assigned. In JavaScript, a double equals tests for loose equality and preforms type coercion. This means we compare two values after converting them to a common type.

2 NaN is a Number


Computer arithmetic cannot directly operate on real numbers, but only on a finite subset of rational numbers, limited by the number of bits used to store them. By definition, NaN is the return value from operations which have an undefined numerical result. Hence why, in JavaScript, aside from being part of the global object, it is also part of the Number object: Number.NaN. It is still a numeric data type, but it is undefined as a real number

3 An Empty Array Equals False

For instance, you can have an array of functions with variables inside the functions. Just like having a function inside of a function (as you may have learned already) the outer function does not have access to the variables of the inner functions. So an array can have information that cant be accessed by the comparison operator, so it can’t declare it true

4 Function Can Execute Themselves

selfinvoking expression is invoked (started) automatically, without being called. A selfinvoking expression is invoked right after its created. This is basically used for avoiding naming conflict as well as for achieving encapsulation. The variables or declared objects are not accessible outside this function.

Share This Post To Your Friends

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *