This

Ange värdet på utrycket nedan.

1 this

2 this.title

🪧 Vi leker med funktioner


let of = {
x: 1,
y: 1,
add: function(x,y) {
return this.x+this.y;
},
mult: function(x,y) {
return this.x*this.y;
}
}
  

🪧 Vi leker mer med funktioner


let of = {
start: 1,
index: 1,
step: 1,
set: function(start) {
this.start = start
this.reset();
return this;
},
next: function() {
this.index = this.index + this.step;
return this;
},
reset: function() {
this.index = this.start;
return this;
},
value: function() {
return this.index;
}
}
  

13 Vad menas med *this* i js kod?

14 Vad används objektet *this* till?

15 Från vilket objekt kommer *this* få sin egenskaper?

16 Vad gör metoden "Object.call"?

17 Ge ett exempel när det kan vara bra att använda *this*.

18 Vilka problem kan uppstå när man använder parametern *this*?

Faci

  1. Window
  2. undefined
  3. Reflektion 💭
  4. Reflektion 💭
  5. Reflektion 💭
  6. Reflektion 💭
  7. Reflektion 💭
  8. Reflektion 💭