查看Boolean.constructor
var bool = true;
var booleanObj = new Boolean(true);
console.log ('typeof bool', typeof bool); # returns 'boolean'
console.log ('typeof booleanObj', typeof booleanObj); # returns 'object'下面的代码行返回:function Function() { [native code] }。如何查看native code
console.log('Boolean.constructor', Boolean.constructor);最后,我怎样才能
var y = Boolean.constructor(true);
console.log('typeof y', typeof y); # returns function然后,输出y:y: function anonymous() { true }。如何解压true
console.log('y:', y);http://jsfiddle.net/9YxkE/
发布于 2014-05-25 10:38:31
Boolean是一个函数。
它的constructor属性是所有函数(即Function函数)的构造函数。
本机代码是Javascript引擎的一部分,通常用C++编写。
如果您愿意,您可以探索V8或SpiderMonkey的源代码。
true是通过调用Function构造函数创建的函数体。
https://stackoverflow.com/questions/23851499
复制相似问题