1

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()
})
Peter Mortensen
31.3k22 gold badges110 silver badges134 bronze badges
asked Mar 30, 2011 at 12:01

1 Answer 1

3
element.remove = function(){
 ...
};
answered Mar 30, 2011 at 12:04
Sign up to request clarification or add additional context in comments.

1 Comment

For some reason, I remember reading that older versions of IE wouldn't let you do stuff like this. Am I making that up? Also, would there be a problem with using element.prototype.remove, or is that where older browsers draw the line.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.