Hey, lastIndexOf seems to be used now and then by some scripts, but is not supported yet. Will it be?
I doubt it will be, and you can define your own function or just use:
var str = 'Hello planet earth, you are a great planet.';
var search = 'planet';
var lastIndex = (str.split('').reverse().join('').indexOf(search.split('').reverse().join('')) - str.length + search.length) * (-1)
Please test this, I haven't :P
Just added - it'll be in version 1.58 :)
@randunel: Hey, thanks. Since one can access Strings on a character level, one can basically implement anything. But given that this is a somehow common function, other people might also miss it. So, might help to have it directly included in the distribution.
Funnily enough I came across it in a function that actually did not need it :)
Don't worry about formatting, just type in the text and we'll take care of making sense of it. We will auto-convert links, and if you put asterisks around words we will make them bold.
For a full reference visit the Markdown syntax.
© Espruino, powered by microcosm.
Report a problem