没有括号的构造函数调用 [英] Constructor invocation without parentheses

查看:105
本文介绍了没有括号的构造函数调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何区别

var obj1 = new Constructor;

var obj2 = new Constructor();

假设构造函数是一个构造函数?

given that Constructor is a constructor function?

推荐答案

根据 MDN docs


[...]new foo相当于new foo(),即如果没有参数列表是
指定,则不带参数调用foo。

[...] "new foo" is equivalent to "new foo()", i.e. if no argument list is specified, "foo" is called without arguments.

这篇关于没有括号的构造函数调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆