# 4.9 this 關鍵字

在 `javascript/practice` 資料夾下，建立 `this.html` 檔案，以便練習。

## 範例1

```javascript
//"use strict";
console.log(this); // window
```

```javascript
"use strict";
console.log(this); // window
```

## 範例2

```javascript
//"use strict";

function test(){
  console.log(this); // window
}
test();
```

```javascript
"use strict";

function test(){
  console.log(this); // undefined
}
test();
```

## 範例3

```javascript
//"use strict";

var myobj = {
  data: "my_str",
  test: function(){
    console.log(this); // myobj
  }
};

myobj.test();
```

```javascript
"use strict";

var myobj = {
  data: "my_str",
  test: function(){
    console.log(this); // myobj
  }
};

myobj.test();
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.webmix.cc/javascript/4.-javascript-chang-yong-nei-jian-han-shi/4.9-this-keyword.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
