showing results for - "context javascript"
Oskar
30 Jun 2020
1console.log(this);
2// Window {0: Window, window: Window, self: Window, document: document, name: "", location: Location, …}
3
4class MyClass {
5	constructor(x, y){
6    	this.x = x;
7      	this.y = y;
8      	this.sum = x + y;
9    }
10	printThis(){
11    	console.log(this);
12    }
13}
14
15myClass = new MyClass(3, 4);
16myClass.printThis();
17// MyClass {x: 3, y: 4, sum: 7}