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
Post a Comment