Wednesday, 15 May 2013

javascript - when is a String not a String? when it doesn't have an includes() method? -


I am trying to write a simple javascript (well coffeescript) test and am confusing something:

  dclib.appendVarToUrl = (Base, K, V) - & gt; Base.includes ("?") ... // dclib.appendVarToUrl (with "some / url", "scores") base, string console.log ("Base is one:", typef (base)) . 5)  

gives me:

  the base is one: string type error: object 'some method' is not included in the URL ' 

So why not a string is one .includes () method? Is it a coffee-wrapper that wears a strange thing?

Ah, it seems that my browser supports it as an ES6 method, but the node Version I am running the unit test on the server, while the method was running fine on the client.

This is an experimental technique, which is part of ECMAScript 6 (Harmony) Proposal.


No comments:

Post a Comment