new的函数如果有return

 1         function FnA() { return { a: 1 } }
 2         function FnB() { return false }
 3         function FnC() { return true }
 4         function FnD() { return 1 }
 5         const aa = new FnA()
 6         const bb = new FnB()
 7         const cc = new FnC()
 8         const dd = new FnD()
 9         console.log('aa', aa)
10         console.log('bb', bb)
11         console.log('cc', cc)
12         console.log('dd', dd)

输出:

aa {a: 1}
bb FnB {}
cc FnC {}
dd FnD {}

如果返回是个对象就会返回这个函数返回的对象,如果不会就创建一个新的对象prototype指向Object