1

When i tried to check for a string pattern using endsWith in node server versioned v0.10.25, it threw an error,

Object ''''''' has no method 'endsWith'

Then i found out from this link, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith, that String.prototype.endsWith will come only from ECMA6. So, what ecma version node v0.10.25 has implemented? which future release of nodejs, i can expect to be ECMA6 compliant?

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
  • Would this answer on a similar question help: [Ecmascript 6 support on Node.js](http://stackoverflow.com/a/26693835/808431) – Raghd Hamzeh Dec 22 '14 at 09:09

2 Answers2

5

It's obvious that if not ES6, it would be implemented in ES5, or the current iteration of jaavacript. Also instead of waiting for it, you could write your own

String.prototype.endsWith = String.prototype.endsWith || function(str){
   return new RegExp(str + "$").test(str);
}
Amit Joki
  • 58,320
  • 7
  • 77
  • 95
3

http://kangax.github.io/compat-table/es6/ here you can find the compatibility chart for ecma-script-6.

and read this answer https://stackoverflow.com/a/13352093/3556874. You can activate the node harmony flag node this way --harmony app.js, to make node compatible with strings endsWith

Community
  • 1
  • 1
Naeem Shaikh
  • 15,331
  • 6
  • 50
  • 88