Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我见过人们使用变量作为对象和函数,如下所示:
myClass();
和
myClass.myMethod();
他们是怎么做到的?
函数是 Javascript 中的对象,因此您可以设置属性(如其他函数或对象):
function myClass() { //blah blah } myClass.myMethod = function() { //your other function } myClass.myMethod();