Search code examples
javascriptgoogle-chromefirefoxlocale

Code not working in firefox while runs fine in chrome


how and why does the following piece of code giving 1 in chrome while it gives 2 in firefox.

    var a = "2014/04/27"
    var b =  "2014/04/09"
    var n = a.localeCompare(b);
    console.log(n);

I am using the above code in my project and it runs fine in chrome but buggy in firefox. Any suggestions or equivalent functions for the above work is welcome. Thank You.......


Solution

  • The function implementation differs for one browser to another.

    Here is the documentation page for Firefox : https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare ...

    ... and see this thread for more infos : http://code.google.com/p/v8/issues/detail?id=459