15.2.3.14-6-2.js (651B)
1 // Copyright (c) 2012 Ecma International. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 es5id: 15.2.3.14-6-2 6 description: > 7 Object.keys - the order of elements in returned array is the same 8 with the order of properties in 'O' (sparse array) 9 ---*/ 10 11 var sparseArray = [1, 2, , 4, , 6]; 12 13 var tempArray = []; 14 for (var p in sparseArray) { 15 if (sparseArray.hasOwnProperty(p)) { 16 tempArray.push(p); 17 } 18 } 19 20 var returnedArray = Object.keys(sparseArray); 21 22 for (var index in returnedArray) { 23 assert.sameValue(tempArray[index], returnedArray[index], 'tempArray[index]'); 24 } 25 26 reportCompare(0, 0);