What is the difference between str[0]and str.charAt(0)? I always access a specific character by simply typing str[i]where iis the index of the character I want to access (counted from 0), but last week I had a good overview of open source JS code and in every single project I seen, people use the method charAt.
str[0]
str.charAt(0)
str[i]
i
charAt
Is there a difference between the two?
[] - A more primitive way to access all types of arrays.
[]
charAt() refers to strings.
charAt()
[], charAt() .
, .
charAt(), , undefined IE7
undefined
, , charAt() undefined, ""
""
""[-4] // undefined "".charAt(-4) // ""
Source: https://habr.com/ru/post/1534006/More articles:How to remove sms from the inbox? - androidPassing dynamic data from a div to another div on the same page - jqueryOSX Pillow Incompatible library version libtiff.5.dylib & libjpeg.8.dylib - pythonHow to wrap datetimepicker js in AngularJS directive - javascriptCan we use the built-in PHP function inside a twig file in symfony - symfonyWhat do ios apps do when they boot? - performanceSelect a row from the data.table with the minimum value - rНежное введение в Haskell: ".... нет единого типа, который содержит как 2, так и" b ". Не могу ли я сделать такой тип? - scalaInno-setup package of all files in a folder except 1 file - inno-setupmatplotlib will show the number again - pythonAll Articles