JavaScript: Strings & Arrays
Page 18
Strings & Arrays
Introduction
This page is under development.
Learn to use basic JavaScript string and array methods such
as slice(), substring(), substr(), join(), push(), pop(), trim(), find(), findIndex()
and many more.
String Methods
Let's try
str.slice(index1, index2)
,
str.slice(-index1, -index2)
and
str.slice(-index1)
,
str.slice(index1)
.
str.substring(index1,index2)
can't accept negative parameters.
str.substr(index1,index2)
where the second parameter specifies the string length.
str.padStart(i1), str.padEnd(i1), trim()
and other string padding techniques.
Array Methods
Array methods include
join(), pop(), push(), shift(), unshift(), splice(),
slice(), concat(), sort(), reverse(),
sort:Math.max(), sort:Math.min(),
isArray(), includes()
and array iteration methods.
Also learn some JavaScript array techniques.
const aCats = ["Burmese","Russian Blue","Lynx"];
Array Length
Use the length
property to
obtain the number of elements in an array.
You can also use length
to
append an array.
The following example appends array cats
.
cats[cats.length] = "Croatian Wild Cat";
Summary
This page is under development.
You learned to use basic JavaScript string and array methods such
as slice, substring(), substr(), join(), push(), pop()
and many more.
Learn JavaScript
JavaScript's the foundation of Web developer and Website design skills. This free and unique JavaScript tutorial includes some new or seldom used, but useful features.