Note: We generally discuss IE and non-ie browsers here. More precise detection needs to be combined with UA and other features for Comprehensive Judgment.
1. Vertical Tab
'\ V' escape problem, using the browser to understand the Escape Character' \ V'
The IE browser cannot recognize \ v as an escape character and directly outputs v
Other browsers (currently verify safari \ chrome) escape to vertical tabs, which is roughly equivalent to "" a space
// IE will generate V1, right-expression + will be converted to String concatenation, but left-expression is empty, will be converted to Number Addition, you can understand why + [] is equal to 0 // so the result of IE + "V1" is nanvar Ie =! + "\ V1"; // false, ie
2: Use the JS engine of the browser to parse different
When we write the JS object of an object with a JSON-like structure, such
{ name: "test", key: "key", value: false,}
The error message of this Code in IE engine is: Unexpected Terminator, because the parsing error of ',' browser after the value ends, therefore, this method makes full use of the browser's error correction function for judgment.
Then [1,] the tostring method called by IE will parse "1," and remove ',' in the standard browser. Note that [, 3, 4,] in the arraylist are distinguished. which indexes are missing? See the description of MDN.
If (! + [1,]) {// ie} else {// standard browser} // operator + when the left expression does not exist, it will try to convert the right expression to number // + [] // + [] the conversion process can be explained in this way // number ([]) // number ([]. tostring () // []. valueof () isn' t primitive // number ("") // 0
Extension: + [] can be viewed
Identify the Browser Based on Feature Detection in the shortest