search

Home  >  Q&A  >  body text

javascript - Questions about string length in Ruan Yifeng's ECMAScript 6 introduction

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

过去多啦不再A梦过去多啦不再A梦2826 days ago683

reply all(3)I'll reply

  • 天蓬老师

    天蓬老师2017-05-19 10:27:44

    Sister, that is not auspicious sign

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-05-19 10:27:44

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

    reply
    0
  • 高洛峰

    高洛峰2017-05-19 10:27:44

    > 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~

    reply
    0
  • Cancelreply