Javascript string subscript get element

in the C language, there is no string type, the string is an array of characters, but there is a string type in js, so in js Why the string can also be obtained through the subscript in parentheses, and what is the difference between str [I] and str.charAt (i) ?
clipboard.png

Jul.19,2021

js We usually create String
var str = "abc"
when manipulating a string, it is converted to a string object
var str = new String ('abc');


jsString

clipboard.png

str[0]String0

charAtStringapi

clipboard.png

:
clipboard.png

when the subscript does not exist, str [index] returns undefined (undefined) and str.charAt (index) returns "(empty string)

The

string is an array-like object with a length attribute, which can be valued by a numeric key (0mem1).
str [I] and str.charAt (i) are essentially the same, but str.charAt (i) is more standard


is no different. There's nothing wrong with it. The standard rule is yes. Let me ask you why strings in js can use both single quotation marks and double quotation marks.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3aab1-2c212.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3aab1-2c212.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?