开发者

Adding methods to a JavaScript object

开发者 https://www.devze.com 2023-02-20 14:27 出处:网络
I have an object that\'s the argument of a function. I want to add methods to those objects, so I can easily perform operations on them.

I have an object that's the argument of a function.

I want to add methods to those objects, so I can easily perform operations on them.

How do I add those methods to the object?

stuff.on('move', function (element) {
    element.remove()
    element.add()
    element.change()
})
开发者_如何学编程


element.remove = function(){
    ...
};
0

精彩评论

暂无评论...
验证码 换一张
取 消