Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在javascript对象的属性中将其作为基本对象的上下文_Javascript_Object - Fatal编程技术网

在javascript对象的属性中将其作为基本对象的上下文

在javascript对象的属性中将其作为基本对象的上下文,javascript,object,Javascript,Object,我想知道我需要做什么才能在java脚本对象的子属性中维护一种类型的(var self=this)耦合。例如,如果我有以下对象: var t = { helpers: { getName: function(){ //how do i preserve this or get the mbase object instance here... //so i can for example do the following:

我想知道我需要做什么才能在java脚本对象的子属性中维护一种类型的(var self=this)耦合。例如,如果我有以下对象:

var t = {
    helpers: {
        getName: function(){
            //how do i preserve this or get the mbase object instance here...
            //so i can for example do the following:
            var self = this;//this is now helpers object, but how to get to base object?
            return self.nickName + "...";
        },
        getTime: function(){

        }
    },
    nickName: 'test'
}
根据我目前的理解,如果该引用是对象的属性,那么它在对象中的引用将直接传递到函数中。因为这个场景是两个对象,所以当我引用(var self=this)时,它是基对象还是“helpers”对象?如果是,我如何到达obj.helpers.get昵称()中的基对象属性,例如“nickNam”


提前谢谢。

t.昵称
应该知道,我已经把这件事复杂化了。谢谢。
t.nickName
应该知道,我把这件事复杂化了。谢谢