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


i'm trying write simple javascript(well coffeescript) test , have confusing:

dclib.appendvartourl = (base, k, v) ->   check base, string   console.log("base a:", typeof(base))   if base.includes("?")      ...   // called dclib.appendvartourl("some/url", "score", 5) 

gives me:

base a: string typeerror: object some/url has no method 'includes' 

so why string not have .includes() method? coffeescript wrapping object in weird way?

aha, looks browser supports es6 method, node version i'm using doesn't. running unit tests on server whereas method ran fine on client.

https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/string/includes

this experimental technology, part of ecmascript 6 (harmony) proposal.


Comments

Popular posts from this blog

c# - ItextSharp font color issue in ver 5.5.4+ -

jquery - Multiple issues with pushstate: history, loading, calling functions -

ios - retrievePeripherals deprecated in IOS7 how to substitude it with retrievePeripheralsWithIdentifiers -