Saturday, June 29, 2019

Difference between JavaScript Engines

Spread operator

JavaScriptCore the JavaScript engine in SAFARI Mac Os and iOS as well as in Chrome iOS implements the spread operator differently than V8 (Chrome) or Spider Monkey (Firefox).


o1 = { id1:{ isSelected: false}, id2:{ isSelected: false}, id3:{ isSelected: false} }
selected = { id2:{ isSelected: true} }
r = {...o1, ...selected}

// Chrome Windows, FireFox Windows, Chrome MacOs
// The order of the key/property is preserved based on variable o1
{ id1:{ isSelected: false}, id2:{ isSelected: true}, id3:{ isSelected: false} }

// Safari Mac, Safari iOS, Chrome iOS
// The order of the key/property is NOT preserved based on variable o1
// The key/property id2 is now at the end
{ id1:{ isSelected: false}, id3:{ isSelected: false}, id2:{ isSelected: true}  }


This is not a bug, as you should not assume the order of the key/property in an dictionary or object.

Issue sorting array of objects in different browser 

Chrome and Firefix Windows will not return the same result.

4 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. wow, your blog is so amazing, your blog is very helpful. I want to share my information with you. Onlive Server is one of the USA Dedicated Server hosting providers. It provides High speed, better performance, technical support, full Security, full root access and, many more at a minimum price.

    ReplyDelete
  3. It's an excellent article, mind-blowing … if you are looking for more information on dedicated server hosting, check out an Italy Dedicated Server Hosting, which is unlike anything else on the market.

    ReplyDelete
  4. Very nice blog, short but very informative on Java Script.
    Read my Blog: Java Performance Optimization and Profiling Techniques

    ReplyDelete