2
Follow
1
Followers
사용자 정의 클래스 멤버 함수에서 _C 함수를 사용할 때 올바른 this가 얻어지지 않습니다.
Created 2019-08-11 14:47:22 Updated 2019-08-11 14:50:47
3
1844
다음 코드를 실행해보세요:
function MyClass()
{
this.m_name = "my name";
}
MyClass.prototype.printMyName = function()
{
Log(this.m_name);
return true;
}
function main() {
var myobj = new MyClass();
myobj.printMyName();
_C(myobj.printMyName);
}
인쇄 결과:
- my name
- null
즉,_C ((myobj.printMyName) 를 호출할 때, 함수 내의 this 는 myobj 객체를 가리키지 않는다.
이 문제를 어떻게 해결할 수 있을까요?
Related Recommendations
Get Started with FMZ Quant PlatformSECURITY BUGI keep getting error: Exchange_GetAccount: Invalid ContractTypeWe have an incredibly profitable market making algorithm for sideways markets on Bitmex - but need expert to help eliminate wait times during downward volatility in the marketError with deribitLimitations of the backtesting engineHow to install ta-lib on linux docker?5.5 Trading strategy optimization5.4 Why do we need an off-sample test5.3 How to read the strategy backtest performance report
Comment
All comments (3)
function MyClass() {
var self = {}
self.m_name = "My Name"
self.printMyName = function () {
Log(self.m_name)
return true
}
return self
}
function main() {
var myobj = MyClass()
myobj.printMyName()
_C(myobj.printMyName)
}
7 years ago
- 1
