方法一:
function f(name) {
if (this instanceof f)
console.log('以构造函数的方式调用')
}
方法二:
function displayError() {
if (this.constructor == displayError)
console.log('以构造函数的形式调用')
}
方法一:
function f(name) {
if (this instanceof f)
console.log('以构造函数的方式调用')
}
方法二:
function displayError() {
if (this.constructor == displayError)
console.log('以构造函数的形式调用')
}
本文标题:判断函数是否以构造函数的形式调用
本文链接:https://www.haomeiwen.com/subject/jvtdjrtx.html
网友评论