JS's let statement on the Android phone side of the QQ browser error problem

Source: Internet
Author: User

about the Let in JavaScript,The Let statement can declare a local variable of a block-level scope and optionally initialize it to a value.
<id= "List"></ul>
var list = document.getElementById ("list");  for (var i = 1; I <= 5; i++) {    var item = document.createelement ("LI");    Item.appendchild (document.createTextNode ("Item" + i));     = i;     function (EV) {        console.log ("Item" + j + "is clicked.") );    };    List.appendchild (item);}           

Click on the content of the Li tag of the page separately, the controller outputs the content separately:

Analytical:

If you use Var instead of let, you will always print out Item 5 is Clicked, because the Var declaration of J is a function-level variable, 5 intrinsic functions point to the same J, and the last assignment of J is 5.

With Let, J becomes a block-level field (that is, a block of curly braces that generates a block-level field each time the curly brace is entered), so 5 intrinsic functions point to different J.

this time, however, it was not about the use of let, but the new project, when it came to the question that the use of a let project could not open the page normally on the Android phone's QQ browser app. First recommend a link: http://ruanyf.github.io/es-checker/index.cn.html (detects if the current browser supports ECMAScript 6)

On the left is the Android QQ app with the results of the browser, and on the right is the Android QQ browser app test results (test PC browser and the phone's other browsers are mostly more than 90%).

My current solution is to change let to Var. Then say the idea of solving this problem, first let is ES6 new syntax, so we need to check which browsers do not support ES6.

Fortunately, actually found the above mentioned test link, really good, directly with the browser to open the link to know its compatibility.

In addition to let the problem, the project used to vue.js, just start function statement is not rigorous, but on the PC side, the other Android browser (in addition to the QQ browser), iOS browser including the Qq browser, can be normal display, but the Android QQ browser is not normal display.

JS's let statement on the Android phone side of the QQ browser error problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.