What is the function of Extracting String Characters in JavaScript
-
I am brand new to coding of any kind. I am reading W3schools, Javascript String Methods, and one of the functions I don't understand is what is the function/purpose of Extracting String Characters? These two codes are particularly unclear to me charAt() and charCodeAt(). When would they be used?
-
I am brand new to coding of any kind. I am reading W3schools, Javascript String Methods, and one of the functions I don't understand is what is the function/purpose of Extracting String Characters? These two codes are particularly unclear to me charAt() and charCodeAt(). When would they be used?
Member 11446034 wrote:
charAt() and charCodeAt()
The
charAt
function[^] returns the character at the specified index. For example, if the string contains "Hello",s.charAt(0)
will return"H"
. ThecharCodeAt
function[^] returns the numeric Unicode value of the character at the given index. For example, if the string contains "Hello",s.charCodeAt(0)
will return72
, which is the Unicode value that represents an uppercase "H". List of Unicode characters[^]Member 11446034 wrote:
When would they be used?
They would be used when you need to extract either a character, or the Unicode value of a character, at a particular index in a string.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Member 11446034 wrote:
charAt() and charCodeAt()
The
charAt
function[^] returns the character at the specified index. For example, if the string contains "Hello",s.charAt(0)
will return"H"
. ThecharCodeAt
function[^] returns the numeric Unicode value of the character at the given index. For example, if the string contains "Hello",s.charCodeAt(0)
will return72
, which is the Unicode value that represents an uppercase "H". List of Unicode characters[^]Member 11446034 wrote:
When would they be used?
They would be used when you need to extract either a character, or the Unicode value of a character, at a particular index in a string.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
good information. :)