-
• #2
I'll look into it - it looks amazingly similar to String.substring though - it seems a shame to have 3 different ways of getting substrings!
For now, something like:
String.prototype.slice = function(a,b) { if (b<0) b+=this.length; return this.substring(a,b); }
will probably do all you need.
-
• #3
Hi Gordon,
Thats true, though slice can also just have one argument. For last element in string you can do string.slice(-1). Which ofcourse you can also do with string.substring(string.lenght-1, string.length). It would be nice to have :)
Regards,
Alex
-
• #4
You can also use
"Hello".substr(-1)
too.I think I can put it in and basically re-use the same code - it's just frustrating that JS has 3 functions which all do basically the same thing in subtly different ways :)
Hi All,
It seems that String.slice() is missing.
http://www.w3schools.com/jsref/jsref_slice_string.asp
I was wondering if this will be implemented in espruino?
Regards,
Alex