简体   繁体   English

为什么调试器会给您“未定义的不是函数”,而不仅仅是告诉您不是函数的属性/变量的名称?

[英]Why does debuggers give you “undefined is not a function” instead of just telling you the name of the property/variable that is not a function?

What is the reason js debuggers gives you "undefined is not a function" instead of just telling you the name of the property/variable that is not a function? js调试器给您“未定义的不是函数”而不是仅仅告诉您不是函数的属性/变量的名称的原因是什么?

example: 例:

a = {
  aFunction: function(){...}
  notAFunction: "foo"
}

a.notAFunction()

Gives: 得到:

undefined is not a function 未定义不是函数

This is more helpful: 这更有用:

property "notAFunction" of object "a" is not a function 对象“ a”的属性“ notAFunction”不是函数

What are the exact obstacles? 确切的障碍是什么?

This is going to be changing very soon, it might already be in Canary too. 这将很快改变,它可能也已经在金丝雀中。

Improved exception messages: https://plus.google.com/+AddyOsmani/posts/DdWkiKsvbA2 改进的异常消息: https : //plus.google.com/+AddyOsmani/posts/DdWkiKsvbA2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么要为变量分配一个函数而不是声明一个命名函数? - Why would you assign a function to a variable instead of declaring a named function? 如果我给你一个函数的引用,你能得到函数的名称吗? - If I give you a reference to the function can you get the name of the function? 为什么在 object 的 function 属性中声明变量之前可以引用它? - Why can you reference a variable before declaring it in a function property of an object? 为什么要将全局变量传递给函数? - Why would you pass a global variable to a function? 您可以将对象类型设置为自定义名称而不是 Javascript 中的函数吗 - Can you set a object type to custom name instead of function in Javascript 为什么JavaScript中的函数不接受未定义的变量? - Why a function in javascript does not accept undefined variable? 为什么定义函数的字符串的求值返回undefined而不是函数? - Why does the evaluation of a string defining a function return undefined instead of the function? 你能得到调用函数的属性名吗? - Can you get the property name through which a function was called? 为什么Node的猫鼬告诉我undefined不是函数? - Why is Node's mongoose telling me that undefined is not a function? 为什么我的setTimeout函数返回“窗口”而不是对象的name属性? - Why does my setTimeout function return “window” instead of my object’s name property?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM