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.
有可能做这样的事情吗?
Foo.add_function = function (callback_name, callback_function) { this.prototype[callback_name] = callback_function; }
我需要以数组表示法向原型添加一个函数。谢谢你。
是的。 Aprototype是普通物体;那会很好用。
prototype
请注意,这仅适用this于函数;否则,prototype将不存在。
this
显然,是的:
http://jsfiddle.net/QUFXU/6/
jsfiddle 很棒,当你想测试像这样的简单东西时,你应该检查一下。