1

WebStorm marks the entire GUID method block as a warning of "Primitive value returned from the constructor will be lost when called with 'new'".

export const GUID = () => {
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
        var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
        return v.toString(16);
    });
};

export const GUID8 = () => {
    return GUID().substr(0, 8);
};

export const GUID4 = () => {
    return GUID().substr(0, 4);
};


export default GUID;

Any Idea why?

Source of the GUID method: https://stackoverflow.com/a/2117523/172815

Community
  • 1
  • 1
Guy
  • 12,488
  • 16
  • 79
  • 119
  • Since you're not returning an object it is unclear to me why that is happening. Does it also happen if you don't use fat arrow functions? You might find this post helpful. http://stackoverflow.com/questions/9468055/what-does-new-in-javascript-do-anyway – HeadCode Oct 12 '16 at 15:42
  • Yep, happens anyhow – Guy Oct 14 '16 at 12:23
  • 2
    It could be a weird IDE thing. Try renaming your functions to begin with lower case. http://stackoverflow.com/questions/26338563/primitive-value-returned-from-constructor-will-be-lost – HeadCode Oct 14 '16 at 21:46

0 Answers0