Harry
Harry

Reputation: 54939

Adding methods to a JavaScript object

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()
})

Upvotes: 1

Views: 867

Answers (1)

Fender
Fender

Reputation: 3055

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

Upvotes: 3

Related Questions