javascript - Questions about string length in Ruan Yifeng's ECMAScript 6 introduction
过去多啦不再A梦
过去多啦不再A梦 2017-05-19 10:25:44
0
3
587

Why I tried it in the chrome browser'吉'.length === 1

过去多啦不再A梦
过去多啦不再A梦

reply all(3)
Peter_Zhu

Sister, that is not auspicious sign

给我你的怀抱

That character is not auspicious, please copy it and try it

小葫芦
> var a = "你好";
undefined
> console.log(a[1]);
好
undefined
> 

length is the number of characters. It doesn’t matter what the storage is.
Strings are all operated on arrays, as shown in the above code.
So the length of the string you take is the length of the array.

Master Ruan, there are times when you feel faint, don’t worry about it~

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template