Why does Firefox 100.0 lead to website bugs?

I happened to see an article on the public account that "Firefox is testing what bugs will be caused by the 100.0 version number". Because the article is hard written and does not understand the principle, the readers are so angry that they just study it by themselves.

Why study

When programmers read technical articles, they pay attention to one cause and effect, but when they see the "reason" described in this article, my fire comes out:

After reading the screenshot above, do you understand why the version number can cause a failure?

Why on earth can the version number cause failures? What happens if you don't read 100.0 or convert it to a string? You said it!

After searching the English report, I found that this "technical article" was a full translation of an English report, but the report only mentioned the string problem without giving detailed reasons, so the editor who only translated the original text could not write it. Of course, the minor editor takes the first place in sending articles. As for whether the content is reasonable or not, it doesn't matter at all.

look into the causes

The example in the English report points to a Github issue, which describes in detail the cause of a bug on a website. I will use an experiment to let you feel the bug.

  1. To browse the web, press F12 to open the console.

  2. Enter the following code on the console:

     let c = "100.0",d="2"; //Enter console.log(d > c); //Enter
  3. Observation phenomenon

If all goes well, your results should be as follows:

This is a very common string comparison problem. Because the ASCII code of 2 is larger than that of 1, the first string comparison results.

For some frameworks or libraries, in order to support the features of different versions of browsers, version strings are used for comparison. For example:

 if(nowVersion > "70"){ //Style 1, Event 1 }else if(nowVersion > "55"){ //Style 2, Event 2 }else{ //Too old,do not support }

Therefore, when the version number is upgraded to 100.0, using string comparison may cause an embarrassment that the supported version cannot be matched, while using numerical comparison is no problem.

other

To a small editor of an official account: "Why does the version number cause potential failures", read your answer carefully. Is that the answer?

As an information technology oriented public account, you should at least write the reason for the problem when writing an article. If you don't know, you can't write it. Look at what is written here. There is a word "but", which is the reason?!

Zimiao haunting blog (azimiao. com) All rights reserved. Please note the link when reprinting: https://www.azimiao.com/8112.html
Welcome to the Zimiao haunting blog exchange group: three hundred and thirteen million seven hundred and thirty-two thousand

Comment

*

*

Comment area

  1. Nurupo 08-23 09:38 reply

    Don't be so angry. Just get used to it~
    In this era of high traffic, they can pull anything in order to catch the eye. When you are free, you should search for articles on the Internet, especially those related to technology:)