在knockout.js 中,为什么“这个"被分配给“自己"? [英] In knockout.js, why "this" is being assigned to "self"?

查看:20
本文介绍了在knockout.js 中,为什么“这个"被分配给“自己"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习 Knockoutjs 教程.有一件事对我来说似乎很奇怪.我目前在第 2 部分:

I am working through Knockoutjs tutorial. And one thing seems weird to me. I am currently in part 2:

http://learn.knockoutjs.com/#/?tutorial=collections

在每个类"的这一部分中,这个"被分配给自我"......第一个不是这种情况?

And in this part in every "class", "this" is being assigned to "self".. it was not the case in the first one?

为什么会有人这样做?是否只是编写特定代码的人对 Python 上瘾了,或者这有什么实际好处?

Why would someone do this? Is it just whoever wrote that particular code has python addiction, or is there some actual benefits to this?

推荐答案

由于this"根据上下文指代不同的对象,因此可以通过将其分配给另一个变量来保存对特定对象的引用,例如self".

Since "this" refers to different objects depending on context, one can save a reference to a particular object by assigning it to another variable, for example "self".

这篇关于在knockout.js 中,为什么“这个"被分配给“自己"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆