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

查看:61
本文介绍了在淘汰表.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

在每个类"的这一部分中,"this"都被分配给"self".在第一个中不是这样吗?

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".

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

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