Alice Xu
Alice Xu

Reputation: 543

remove javascript prototype function

I use some kind of a library that declare

slide.prototype.removeClick= function(){
//something here
}

How to remove the prototype of removeClick in my js file? I can comment out or delete that chunk in the library js but that's not a good practice.

Upvotes: 0

Views: 1788

Answers (3)

Himesh Aadeshara
Himesh Aadeshara

Reputation: 2121

here function created using 'Prototype' is a kind of 'Object' and we have facility of deleting object so as @jfriend00 said you can delete it using 'delete'.

and i would suggest if you are not gonna use that prototype function then just delete that particular lines of code man..!!! that will reduce your Complexity.

Upvotes: 0

jfriend00
jfriend00

Reputation: 707546

Since presumably some code is going to call that function and you probably don't want a script error to occur at that point, you can just replace the existing function with your own dummy function by just reassigning the removeClick method to a new dummy function:

slide.prototype.removeClick = function(){}

Upvotes: 1

Gulfaraz Rahman
Gulfaraz Rahman

Reputation: 407

Try delete slide.prototype.removeClick or slide.prototype.removeClick = null

Simplest way without intrusion

Upvotes: 0

Related Questions