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

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -