无涯教程-constructor函数

38 阅读1分钟

构造函数返回对创建原型的字符串函数的引用。

constructor - 语法

string.constructor

constructor - 返回值

返回创建该对象的函数。

var str=new String( "This is string" ); 
console.log("str.constructor is:" + str.constructor)

运行上面代码输出

str.constructor is:function String() { [native code] }

参考链接

www.learnfk.com/es6/es6-str…