Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/436.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/55.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,我手臂上有一种奇怪的行为: 我声明了一个对象,属性将按顺序执行,它们是这样做的,但在一个对象中有一个简单的传递,其中没有写入任何内容 我有范围问题吗 这是一个代码片段,其中verteX是我的对象 stepsCalcul: function() { var test = 2; verteX.testCheck = test*2; //returns undefined alert('stuff') //alerts nothing console.log("logged stuff

我手臂上有一种奇怪的行为:

我声明了一个对象,属性将按顺序执行,它们是这样做的,但在一个对象中有一个简单的传递,其中没有写入任何内容

我有范围问题吗

这是一个代码片段,其中verteX是我的对象

stepsCalcul: function() {
  var test = 2;
  verteX.testCheck = test*2; //returns undefined
  alert('stuff') //alerts nothing
  console.log("logged stuff")//logs nothing
  verteX.mouseCoordinates();
  return true;
},
我也会把它分类


谢谢

根据您的小提琴,您没有调用
init
函数


替换
verteX.init带有
顶点.init()

小提琴中的问题是您没有调用
init
方法。这里有一个问题。我想我被mousemove事件完全误导了,调用jquery方法的对象属性是否独立执行?从你的小提琴上看,
verteX。MouseCoordination
不包含函数,而是一个jquery对象。顺便说一句,您将一个处理程序绑定到“mousemove”事件,同时将jQuery对象影响到
mousecordination
。记住,
verteX.init
是函数,
verteX.init()
是函数返回的结果。函数只是对象,很像int或字符串,您可以传递或调用它们。感谢您的解释,我错误地认为对象属性在默认情况下是函数。