mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-11-03 23:00:58 +00:00 
			
		
		
		
	This commit introduces a way to get an object's own properties in the
correct order. The "correct order" for JS object properties is first all
array-like index properties (numeric keys) sorted by insertion order,
followed by all string properties sorted by insertion order.
Objects also now print correctly in the repl! Before this commit:
courage ~/js-tests $ js
> ({ foo: 1, bar: 2, baz: 3 })
{ bar: 2, foo: 1, baz: 3 }
After:
courage ~/js-tests $ js
> ({ foo: 1, bar: 2, baz: 3 })
{ foo: 1, bar: 2, baz: 3 }
		
	
			
		
			
				
	
	
		
			21 lines
		
	
	
	
		
			514 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
	
		
			514 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
load("test-common.js");
 | 
						|
 | 
						|
try {
 | 
						|
    let names = Object.getOwnPropertyNames([1, 2, 3]);
 | 
						|
 | 
						|
    assert(names.length === 4);
 | 
						|
    assert(names[0] === "0");
 | 
						|
    assert(names[1] === "1");
 | 
						|
    assert(names[2] === "2");
 | 
						|
    assert(names[3] === "length");
 | 
						|
 | 
						|
    names = Object.getOwnPropertyNames({ foo: 1, bar: 2, baz: 3 });
 | 
						|
    assert(names.length === 3);
 | 
						|
    assert(names[0] === "foo");
 | 
						|
    assert(names[1] === "bar");
 | 
						|
    assert(names[2] === "baz");
 | 
						|
 | 
						|
    console.log("PASS");
 | 
						|
} catch (e) {
 | 
						|
    console.log("FAIL: " + e);
 | 
						|
}
 |