mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-10-31 05:10:57 +00:00 
			
		
		
		
	 c06a6c67d5
			
		
	
	
		c06a6c67d5
		
	
	
	
	
		
			
			We already have "global" as a way to access the global object in js(1) (both REPL and script mode). This replaces it with "globalThis", which is available in all environments, not just js.
		
			
				
	
	
		
			15 lines
		
	
	
	
		
			263 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			15 lines
		
	
	
	
		
			263 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| try {
 | |
|   assert(typeof this === "object");
 | |
|   assert(this === globalThis);
 | |
| 
 | |
|   function Foo() {
 | |
|     this.x = 5;
 | |
|     assert(typeof this === "object");
 | |
|     assert(this.x === 5);
 | |
|   }
 | |
| 
 | |
|   new Foo();
 | |
|   console.log("PASS");
 | |
| } catch (err) {
 | |
|   console.log("FAIL: " + err);
 | |
| }
 |