function Test() {
方式一:
if(this instanceof Test) {
console.log('success')
}else {
console.error(' Test must be with new.')
}
方式二:
if(new.target==='undefined') {
console.error(' Test must be with new.')
}
}
let aa = new Test()
let bb = Test()
console.log(bb)