JavaScript is one of the most popular programming languages today, but popular is also a side effect of the language's own features, no matter how wonderful the language is, thousands of programmers make a bunch of bugs every day. Don't laugh at others, maybe you are one of them.
To give you an example, here are a few short, fully valid JS clips (you can experiment on your console):
Copy Code code as follows:
typeof NaN = = ' Number '/true
Infinity = = 1/0//True
0.1 + 0.2 = = 0.3//False, same as front parenthesis
"3" + 1//' 31 '
"3"-1//2
Do you still believe in your own javascript?
1, JS the smallest value
Copy Code code as follows:
Number.min_value > 0; True
Number.min_value for JavaScript can be expressed as a minimum value of 5e-324, however, is the most nearly 0 of JS number
2. String connection
Copy Code code as follows:
("foo" + + "bar") = = "Foonan"//true
"Why I am" + typeof + ""//Why I am number
js resolves to "foo" + (+ "bar"), which will turn "bar" into a number
3. parseint function
Copy Code code as follows:
parseint (' 06 '); 6
parseint (' 08 '); 0 note, Google New version has been revised
parseint (null,) = = =/True
4, NULL is not object
Copy Code code as follows:
typeof Null//Object
Null instanceof Object//False
5. Return content
Copy Code code as follows:
function Myjson ()
{
Return
[
2
]
}
Myjson (); Undefined
Return must be returned on the same line
6, odd numbers.
Copy Code code as follows:
012 = =/False
' 012 ' = =/True
"3" + 1//' 31 '
"3"-1//2
0.1 + 0.2 = = 0.3//False
0.1 + 0.7 = = 0.8//False
0.2 + 0.7 = = 0.9//False
9999999999999999//10000000000000000
9999999999999999-1//10000000000000000
111111111111111111111//111111111111111110000
7, the weird parameters
Copy Code code as follows:
function Hello (what) {
Alert (arguments[0]); Vicky
what = "world";
Return "Hello," + arguments[0] + "!";
}
Hello ("Vicky"); "Hello, world!."
8, let the big-head equals sign
Copy Code code as follows:
Nan = = nan; False
[] = = false; True
"" = = false; True
NULL = = FALSE; False
[] == ! []//True
Window.window = = window/True
Window.window = = window//False, some browsers are true
window = document//True, some browsers are false
("0" && {}) = = 0//False
(0 && {}) = = 0/True
0 = "0"//True
[] = = 0//True