Javascript knowledge


1, all values are considered true or false value, however undefind, null, NaN is false, but it does not mean false.

2, NaN represents a non number does not indicate a fixed value, so any value not equal NaN (NaN! = NaN).

3, the logic operation is not necessarily returns a Boolean value, which is different from other programming languages ​​(but this does not affect the conditional). Such as: var a = "abc"; var b = (a || null); // b equals abc, rather than boolean true

4, this usually points to key environmental object functions where the current call. The: function test () {console.log (this);} test (); new test (); // first time, this refers to the window; this refers to the second object itself.

5, in a single page, the function call can appear before the function statement. Such as: test (); function test () {alert ( "test");}

6, immediately call the function expression is usually placed inside the grouping operator, it is a better way. Such as: var test = (function () {} ());

7, all global variables are properties of the object window. Such as: var a = 123; alert (window.a);

8, built-in objects divided into three groups: browser object (window), the document object (document), a global javascript object (String, Number, Date ...).

Guess you like

Origin www.cnblogs.com/zbseoag/p/10983873.html