[英]Chrome Web inspector shows unusual symbol when calling prototype method in console
So I have this function called "createGameObjectConstructor" which takes a function and a prototype adds the prototype and a method to the function then returns the function.It can be used like this 因此,我有一个名为“ createGameObjectConstructor”的函数,该函数带有一个函数,原型向该函数添加原型和方法,然后返回该函数。可以像这样使用
Monster = createGameObjectConstructor(function () {
this.evilness = 9001;
}, {
eatHuman:function () {
console.log('human consumed');
}, type:'scary'
});
and "createGameObjectConstructor" looks like this 和“ createGameObjectConstructor”看起来像这样
createGameObjectConstructor = (function () {
var recent = function () { //every actual object constructor will share this method
return (instance.length> 0) ? instance[instance.length - 1] :null;
};
return function (constructor, prototype) { //createGameObjectConstructor
var instanceArray = new Array();
constructor.prototype = prototype;
return function (){ //actual object's constructor
var instance = new constructor();
instance.constructor = constructor;
instanceArray.push();
return instance;
};
f.recent = recent;
return f;
}
}());
But when I call Monster().eatHuman();
但是当我打电话给
Monster().eatHuman();
in Chrome's console it returns the function undefined but with a weird arrow next to it, is this because my bizarre coding somehow led it too eval the code or something? 在Chrome的控制台中,它返回的函数未定义,但旁边带有一个怪异的箭头,这是因为我奇怪的编码在某种程度上导致了它对代码的评价吗?
here's a fiddle http://jsfiddle.net/UZmL9/ 这是一个小提琴http://jsfiddle.net/UZmL9/
This just means the return value of the function is undefined
. 这只是意味着函数的返回值是
undefined
。
All JavaScript functions return undefined
by default if no explicit return
statement is found. 如果未找到显式的
return
语句,则所有JavaScript函数默认都返回undefined
。
function foo(){
console.log("Hi");
}
foo(); // you will get the same 'undefined'
But 但
function foo(){
console.log("Hi");
return 5;
}
foo(); // you will get 5 with that arrow
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.