1

In js I'd do:

delete myobj.prototype["mything"]

How is this accomplished with clojurescript?

1

2 Answers 2

1

Just use built-in google closure wrapper around delete:

(goog.object.remove (.-prototype myobj) "mything")
Sign up to request clarification or add additional context in comments.

Comments

0

I have never try it in production mode but this problem seems to be fixed according to this other os question ClojureScript: How to add method via prototype to JS Object?

And this is my proposal to fix your problem:

Adding prototype property

(set! (.-foo (.-prototype js/String)) (fn [] "bar"))
(.-foo "test")
=>#<function (){return "bar";}>

Nulling this property

(set! (.-foo (.-prototype js/String)) nil)
(.-foo "test")
=> nil
(undefined? (.-foo "test"))
=> false

And following the "undefined" mozilla description specification .

undefined is a property of the global object, i.e. it is a variable in global scope. The initial value of undefined is the primitive value undefined.

Then I'll try with js/undefined

(set! (.-foo (.-prototype js/String)) js/undefined)
(.-foo "test")
=> nil
(undefined? (.-foo "test"))
=> true

good luck!

2 Comments

As far as I can tell, this doesn't delete the property from the prototype object, but just sets it to null.
@ngieschen You were right! I updated my response. Hoping now works for you!

Your Answer

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.