일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- JavaScript
- Props
- API
- evm
- built in object
- middleware
- web
- concept
- error
- CLASS
- REACT
- Redux
- bitcoin
- tailwindcss
- solidity
- nextJS
- typeScript
- HTML
- hardhat
- 기준
- node.js
- CSS
- blockchain
- Ethereum
- graphQL
- SSR
- Interface
- useState
- 삶
- express.js
- Today
- Total
목록this (3)
ReasonJun
In TypeScript, the this keyword is used to refer to the current instance of an object or class within a method or function. It represents the context in which a function is called or an object is accessed. The behavior of this can vary depending on the context in which it is used. Let's explore some common scenarios: In Object Methods: When this is used inside a method of an object, it refers to..
// this binding // 'this' is dynamically determined by the caller! function Hello(name) { this.name = name; this.printName = function () { console.log(`My name is ${this.name}`); }; } function YourName(name) { this.name = name; this.printName = function () { console.log(`Your name is ${this.name}`); }; } const youjun = new Hello('youjun'); const neo = new YourName('neo'); youjun.printName(); // ..
In JavaScript, the this keyword refers to the context in which a function is executed. It is a special keyword that provides a reference to the object on which a method or function is being invoked. The value of this is determined dynamically at runtime based on how a function is called, rather than being lexically bound during the function's definition. The behavior of this depends on the invoc..