I remember that the most commonly used method for Downing many source codes on the Internet is:
var ie = document.all();
This is because the IE browser has the all method under document, but the so-called standard browser does not, so for a long time, this is a very Universal method.
After that, everyone began to pursue brevity, just like a method that became popular after that:
var ie = ! "v1";
This is determined by taking advantage of the fact that IE does not support vertical tab characters. It is shocking to only have 7 characters, but This record was broken by a Russian earlier this year, who only needed 6 characters to complete it.
We will not discuss what this character can do for the time being, but think of it as a kind of research, or if you say it is idle, then it will be okay (complaint~).
var ie = ! - [1,];
In fact, its principle is very simple. [1,] will return the string "1" in a standard browser, which is equivalent to calling [1,].toString, while IE will return "1,". But in this way, both IE and the standard will pass the detection, so using a negative sign to force conversion to a number, the standard can be successfully converted to 1, and 1 will be automatically converted to true in the if, while IE will be converted to NaN, and then automatically converted to false! View DEMO.
Simple, right? There must be many people thinking like me, why didn’t I think of this? Yeah, why didn’t I think of that? (laugh~)
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn