Home  >  Article  >  Web Front-end  >  js The shortest IE browser judgment code in the world_javascript skills

js The shortest IE browser judgment code in the world_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:26:42857browse

var ie = ! "v1";

Only 7bytes required! See this article, "32 bytes, ehr ... 9, ehr ... 7!!! to know if your browser is IE", which tells how foreigners change the judgment of IE from 32 bytes The story of reducing it to 7 bytes step by step

But this record was broken by a Russian on January 8 this year, and now it only has 6 bytes! It uses the toString method of IE and standard browsers in processing arrays made of differences. For standard browsers, if the last character in the array is a comma, the JS engine will automatically remove it. See details here Congratulations, Aleko, you are truly my idol!

var ie = !-[1,];


[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute
]


If from non IE's angle determination can save one bit, because when we do compatibility, in most cases, IE and non-IE work.

var notIE = -[1,];

[Ctrl A select all Note:
If you need to introduce external Js, you need to refresh to execute ]
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