# This
```
author: krm
created: 2023-10-10
status: alpha
```

Ange värdet på utrycket nedan.

# 1. 🎯 this

- Window

# 2. 🎯 this.title

- undefined

# 🪧 Vi leker med funktioner

```js

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

## 3. 🎯 of.add()

- 2

## 4. 🎯 of.mult()

- 1

## 5. 🎯 of.x=2;of.add()

- 3

## 6. 🎯 of.x=3;of.y=5;of.mult()

- 15

# 🪧 Vi leker mer med funktioner

```js

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;
    }
}
```

## 9. 🎯 of.value()

- 1

## 10. 🎯 of.next().next().value() 

- 3

## 11. 🎯 of.set(5).next().next().value();

- 7

## 12. 🎯 of.set(5).next().next().reset().next().value()

- 6

# 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*?

