AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Array js slice9/14/2023 ![]() ![]() ![]() The reason for this change is to enable slice to behave rationally for Array subclasses. The splice () method is used to add or remove elements of an existing array and the return value will be the removed items from the array. In the default case like above, this will be the a new Array instance using the Array of the realm associated with the this value. The slice () method returns a shallow copy of a portion of an array into a new array object selected from start to end ( end not included) where start and end represent the index of items in that array. In ES6 slice returns an object that is determine based upon the actual this value passed to slice. The problem is that in ES<6 slice always returned a new Array instance using the Array of the realm associated with the invoked slice function. instanceof is not a reliable test for array-ness when objects flow between realms. var g = newGlobal( "new-compartment") //or any non-standard mechanism to get a handle on another realm's global objectĪlso note that if the instanceof tests above were replaced with Array.isArray(g.a) you would get all trues in both ES5 and ES6. Here is one of the test cases André is talking about. ![]()
0 Comments
Read More
Leave a Reply. |