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()
})
share|improve this question

feedback

1 Answer

up vote 3 down vote accepted
element.remove = function(){
    ...
};
share|improve this answer
+1 for sugar free javascript. – noiv Mar 30 '11 at 12:38
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. – btleffler Aug 8 at 13:41
feedback

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.