<< Your code has this in it: Object.prototype.toString.call(this)
which is something you usually do not do. The first argument to the .call function becomes "this" in the context of the function which is "cheating" and bypassing prototype inheritance. I consider .call equal to reflection in Java. You should be doing this.toString(). >> This is because some primitive types do not support toString undefined.toString() VM188:2 Uncaught TypeError: Cannot read property 'toString' of undefined at <anonymous>:2:10 at Object.InjectedScript._evaluateOn (<anonymous>:895:140) at Object.InjectedScript._evaluateAndWrap (<anonymous>:828:34) at Object.InjectedScript.evaluate (<anonymous>:694:21)(anonymous function) @ VM188:2InjectedScript._evaluateOn @ VM34:895InjectedScript._evaluateAndWrap @ VM34:828InjectedScript.evaluate @ VM34:694 Object.prototype.toString.call(undefined) "[object Undefined]" So it becomes a rule of thumb to use Object.prototype.toString rather than call .toString on the object and sometimes have JS throw an exception See this: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString On Tue, Sep 8, 2015 at 9:45 AM, Thomas Heller <th.hel...@gmail.com> wrote: > > > > > var x = T > > x.prototype.whatAmI() > > prints: {type: "[object Object]", isEqualToPrototype: true} <---- > because 'this' in whatAmI now points to T.prototype > > > > The thing is that you are not supposed to call methods on the prototype > directly. > > Your code has this in it: > > Object.prototype.toString.call(this) > > which is something you usually do not do. The first argument to the .call > function becomes "this" in the context of the function which is "cheating" > and bypassing prototype inheritance. I consider .call equal to reflection > in Java. You should be doing this.toString(). > > I cannot explain prototype inheritance well enough and will probably only > cause more confusion at this point. [1] does a way better job than I ever > could. > > Cheers, > /thomas > > [1] > https://developer.mozilla.org/en-US/docs/Web/JavaScript/Inheritance_and_the_prototype_chain > > -- > Note that posts from new members are moderated - please be patient with > your first post. > --- > You received this message because you are subscribed to the Google Groups > "ClojureScript" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojurescript+unsubscr...@googlegroups.com. > To post to this group, send email to clojurescript@googlegroups.com. > Visit this group at http://groups.google.com/group/clojurescript. > -- Note that posts from new members are moderated - please be patient with your first post. --- You received this message because you are subscribed to the Google Groups "ClojureScript" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojurescript+unsubscr...@googlegroups.com. To post to this group, send email to clojurescript@googlegroups.com. Visit this group at http://groups.google.com/group/clojurescript.