JS Numeric type 0 start automatically converted to 8 binary

Source: Internet
Author: User

Title, today in the project update found the JS of this automatic conversion problem, the code is as follows:

var num = 0110;

Render:function (num) {
var html= "<a href=\" javascript:viewaccountinfo (' <%=path%> ', "+num+") \ ">" +num+ "</a>";
return HTML;
}

A hyperlink was made to bind the specified number to the Viewaccountinfo method, and the previous run had no problem until

This morning showed a number 0, originally should pass 0110 to the backstage, but the background has been the error message that the specified index could not be found,

The front desk alert found that the pop up unexpectedly is 156, and then began to compare database, debug, run process, to determine the background data no problem.

Heartbroken 0110 changed to 1110 after the problem unexpectedly good, immediately take this as a breakthrough Baidu, sure enough, JS in the value transfer process

The 0 or 0X will be automatically converted to the head, 0 will be converted to 8 (that is, 156), the beginning of 0 x will be out of 16 into the system.

Know the problem after the good run, directly to the string form as follows:

var html= "<a href=\" javascript:viewaccountinfo (' <%=path%> ', ' +num+ ') \ ">" +num+ "</a>";

Have you seen where the change is? o (∩_∩) o ha! , just add a set of single quotes to Num's double-quoted ". It's that simple.

JS Numeric type 0 start automatically converted to 8 binary

Related Article

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.