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.
我想将自己的对象和函数添加到 JavaScript 的导航器对象。我想写一些类似的东西,我自己的对象navigator.AAA.BMethod();在哪里,是要调用的方法。AAABMethod
navigator.AAA.BMethod();
AAA
BMethod
有没有办法做到这一点?
我没有看到这样做的充分理由,无论如何你可以这样做:
navigator.AAA = { BMethod: function () { alert('Hello'); } };