I’m trying to find a work around for some code that works in Firefox but not other browsers, currently the function looks like this:
function capitalise(myString) {
// Extract 1st char (b) and rest of string (c) then return it with b capitalised
var [a, b, c] = /^(.)(.*)$/.exec(myString);
return b.toUpperCase()+c;
}
Which works perfectly in Firefox but Chrome and Opera won’t allow it. Can anyone suggest a decent work around?
I use the same var [ thing1, thing2, thing3 ] = regex.exec(str); syntax for various things in the script I’m writing at the moment.
I suppose this would work in other browsers:
Or alternatively: