3 ms·
There's an error in the section on literals. Literals used outside of classes do not have to be const. Not sure where that notion came from, but this is totally
by spankalee 12y ago
There's an error in the section on literals. Literals used outside of classes do not have to be const. Not sure where that notion came from, but this is totally valid:
var l = [];
Also, the example of looping over characters in a String using substring is very odd and expensive. Generally, if you want to iterate over a list of single-character Strings, you'd use String.split():
for (var c in str.split('')) {}
split('') is necessary to be unicode safe. There's also String.codeUnits and String.runes (an iterable of code-points).