Why can't I use "this" inside the inner function?

I am new to JavaScript. I have the following script working, var navRef = this.navigator; function onSearch( templateName) { navRef.onSearch(); } but not the one below and I am trying to understand why? Any help is appreciated. (navigator is sent as an argument to this object). function onSearch( templateName) { this.navigator.onSearch(); }
It's not possible to answer until you show us how you call onSearch and where you define your code. I suggest you create a jsfiddle.net demo.

以上就是Why can't I use "this" inside the inner function?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准