[removed] Have we always been able to index into a string like it's an array?

前端 未结 3 729
余生分开走
余生分开走 2021-01-23 21:44

I\'ve always thought that if you want to access the nth character in a string called str, then you have to do something like str.charAt(n). Today I was

3条回答
  •  执笔经年
    2021-01-23 22:11

    As long as I can remember, but:

    Array-like character access [...] is not part of ECMAScript 3. It is a JavaScript and ECMAScript 5 feature.

    (...and not supported in all browsers) See here.

提交回复
热议问题