Javascript Creating Short Guid - toString () Weird Behavior in IE

I convert guid and then I convert it to base 16 with parseInt (), then I show it to generate a short guid.

It works fine in Chrome and FireFox, but not in IE.

Here is the code:

var guid32 = function () {
    "use strict";
    return "xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g, function (c) {
        var r = Math.random() * 16 | 0, v = c === "x" ? r : (r & 0x3 | 0x8);
        return v.toString(16);
    });
};

var shortGuid = function () {
    "use strict";
    return parseInt(guid32(),16).toString(36);
};


for(var i =0; i < 100; i++)
{
    $("#guids").append("<p>"+ shortGuid() +"</p>")
}

This is where guid32 () is executed .

Here's the script to check: https://jsfiddle.net/domwu51r/

Why is it different in IE, and how can I solve it?

I assume that the implementation in IE toString () is different from Chrome and FireFox.

How can I save the created guid without scientific notation?

------------------------------ ------------- EDIT ------ --------------

. toString (36), . , , IE, .

+4

Source: https://habr.com/ru/post/1617632/


All Articles