HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
Javascript String Methods.pdf
1. TAVASCRIPT STRING METHODS
Javasczipt Strino_length
The length property Teturns the
Tumber ot characters in a
Stinp
LengthSyntax -
-@jam.fronterdey
str lerpth
HeTe, stT is a
sting
Length patameters
he length property does nötake
any parameters.
.length Retuan value
Returns Tumber of characterin
a string
Note Jhe lstmg.lengihl prepertyreun
the code units n the UTÉ-16
Staing format.
ExAMPLE
A Let etving " JAVA SCRIPT"
shingl.tength ;
le Len
console. Loq (len) Ouput:-10
2. JAVASCRIPT STRTNG chaTAA O
charAt Omethod rekuns thecharaeter
at the specitied index in a
shing.
Example
Const sbing= "Hello
World";_
let indexi strinp.chaAt
(1);
Console.log
("Characleris "tindexi);
Oulput - Chatacterat index1 ise
L Character is e
charAt) mtaX -@iam.fontendey
Str charAt Cindex)
chaTAt U paramerers
index - An integer betoeen Oand
strlenpth-1. A index cann be
Converked to imteger or is not povided,
the dedault value. o is used.
Note; Jhe su.length| tekuans the
length o ä g'iven stimg.
3. JAVASCRIPT Strino includes()
The includes(mcthod checks it
One shinp can betound inside
another shing
Example:
Const mes.sage= Javaseript is tm';
letresult =message.includes("Java);
Console.log (zesulk);
I Output: true
@iam fronlendev
includes () Syntax
S. incuces (SearchSting, position)|
ineludes s () Paramekr.
SearchShing -
A starnp to be
Searched for othin Sto.
position (ophonal)- By defautE,it
s O.
4. incudes () Retuan value
Retums true it Search Staing is
ound anyohere oithin Str
Retuans talse it SeachStaingis
Totoumd anyuoheTe othm shr.
Note: he includes() mehodiS
ease sensitive.
-@iamfunterdev