CSS Unit 2
CSS Unit 2
Array, Function
CHAPTER 2
and String
Syllabus
2.1 Aray: declaring an Array, Initializing an Array, Defining an Array
elements, Looping an Array,Adding an Array elements, Sorting an
Array elements, Combining an Array elements into a String,
Changing elements of an Array, Objects as associative Arrays.
2.2 Function : defining a Function, writing a Function, adding an
arguments,scope of variable and arguments
2.3 Calling a function : caling a function with or without an argument,
calling function from HTML, function calling another function,
Returning a value from a function
2.4 String : manipulate a string, joining a string, retrieving a character
from given position, retrieving a position of character in a string,
dividing text, copying a substring, converting string to number,
numbers to string, changing the case of string, finding a Unicode
of a character-charCodeAt(), fromCharCode().
2.1 ARRAY
Example
var worSyntax .bat We var
war Example Client
NewstringArray[0] Instance)
Example
(Array
var var var var var Example Literal)
var(Array
stringArray mixedArrayboolean decimalstringArray
numericArray ways, separated by Assignment
Initialization
initializing
An and position,
identified Array 2.1.2
mixedArray arrayName weneed (3stringArray
numericArray
) Side
Syll. do
w.e.f array elements notcreate toUsing Scripting
Array Array array contains
next by Defining = have =
mic ="one": = = =
literal,
in
all
=
new an =new Language
new [1, = = "'o=
ne", JavaScript commas. operator
is can is its new instance
[true. [1.1, [1, the the to Array new
Array): "two", be index
1 a Array(elementl,
Array1, provide Array
2,3,4}; array array position list and Array
year false, 1.2, "two", process
retrieving (=) Constructor of 0% (MSBTE)
"three", can position. of (3):
9-20) 1.3]; "three'): instance elements is elements Initializing "two", value array
false, and
be of used
D5-16 4): defined assigning by 3.element2, explicitly. by
true): soThe
and its to on. "four'): passing (Array,
should assign first and
array index an
and values element each Function
constructor. be position. Array element3,... arguments
initialized values
placed element
to inElements and
Neo
ns an to an
in
array; an array elementN); in String)
in in constructor
parenthesis
three array Pg.
while stores the
no.
different elements array (2-3)
at
and array 0h is
so
w Rose
Output </html ></script >
</body>
document.write forflowers(1]
flowers(2]
Hibiscus' : flowers(0j
= :Rose'
Mogra' = : =<head><title>
var <body
<script > > <html> numericArray[0]=
numericArray|l]
numericArray[2]
Constructor)
Example
var(Array 3: ="three";(2] string Client
= 2,= 1:stringArray
var stringArray
ll. (var flowers UQ. numericArray
i= mixedArray Array[1] Side
.f
names Write
of3 Scripting
0; = [3]
c (flowers i< new = =
a "'two":
flowers.length; Display Java = = "four"; Language
Array new
flowers. new
[i] script
ear +'<br>); ): Array(1,
Array Array
(3):
(MSBTE)
0) The that
i++) Elemnents script "two".
initializes
A) then 3,
</title "four"): (Array,
MSBTEdisplays an
></head> array Function
-
elements.
array
Q. called
1(d), and
h-Neo P String)
W-19, flowers
Pg.
2 with
Marks
ie
and
eos over
String)
the
elements Pg.
no.
(2-5)
of
Client
(New The method
push) The emp.forEachimyFunction): <html>
var <body><head>GQWrite Example
a Shiva Lalit RaviOutput <html><body > myFunction(item)
function
<iscript> <script>
push) emp curentValue arrayan
of
function(currentValue,
ar index Side
Syl. built-in 2.1.4 document.write(
= <title> (optional) Scripting
w.e.f [Ravi", (optional)
method
methods the
academic Adding Array Language
use -
adds Lalit"."Shiva"l: the - - the
itenm+
push) Example forEacho of array the value
year an an index (MSBTE)
"<br of index,arr)
element and Array the
of
19-20) </itle> of an
unshift0 >: function the array
Elements current
at )-a
(D5-16A) the </head> current
end use elements function (Array,
with
of to element
the add syntax Function
elements to
array. and be
ch-Neo
Pub example. run and
to for String)
an each
array. P9
element
for ><html>
empvar <body Array Example Client
Prashant"); <seript>
New var <body><head><html> Example
GQ. I
methodPrashant
Theunshift) </body>
Shiva Lalit RaviOutput </html> emp.push("Prashant"):
</seript>=[Ravi"."Lalit'."'Shiva"]:
<script>
Examnle</title></head>
<head><title> GQ. I
emp (i=0:
Syll.
unshift() document.write(emp[i]
"<hr>): + Side
= <title> Write i<emp.length; Scripting
"Lalit,"Shiva"];
w.e.f
method
te
the the
nm Array use Language
use
of adds of
Example unshift) it push).
an +) (MSBTE)
element method
</title method
></head at with
with the (Array,
beginning syntax
> syntax Function
and
example.and
of example and
the
array. String)
Pg.
no.
(2-7)
for Client
(New
ad><title>Sorted <script>
<body>
Ravi Output <html>
<body > <html > UQ.
Example
alternative
order.
sort
compareFunction
array.sortícompareFunction )elements The method
Syntax sort0 A Shiva Lalit Prashant
Note (i=0:i<emplength;
document.write
+<br>;
(empi) Side
Syll. JavaScript 2.1.5
orderWrite Scripting
demic in
alphabetical methods: Also,
following
arr.pop()-
arr.shift)
a Sorting
Java Array we Language
: - can
Script It i+
year Array is order.object anextractsextracts
remove
optional. Array +)
(MSBTE)
code
19-20) < has an an
title
to a Elements item item elements
D5-16A) ></head> display It built-in
represents from from (Array,
MSBTE the from
5 method the
elements end, beginning Function
a beginning
ch-Neo
Put a -Q. function
3(c), sort)
and
of
and String)
array that for
W-19,
sorting ending
in provides
4 Pg.
Markssorted n
array using
an
var Scripting
Client
Side
<head><html> Example jdefault
GQ. array.separator:
OR Syntax
oin(separator)array.join() metjohinod) a After BeforeOutputdocument.write("After > sorted emp<script >
Sorted: var
"+sorted):
>document.write("
<lhtml></body</script
t.w(Nrite(arr.
ew join(|) : var <body>
<script>
arr its The The 2.1.6 Sorted:Sorted:
Syll. = value default =TRavi""Lalit"
=
<title> Write elements join) emp.sort0:
we.f [1.2. It Akash, Ravi,
method Combining
is
the is value Before
comma Language
ademica 3,4, Array use Optional of Lalit, Lalit.
is the Sorted:
5. of a is "Shiva"Akash""
Example</itle></head>
6
]; join()
(.)
i.e.,
commastring used Prashant,
an
Shiva,
"+enp
(MSBT
Client
(New <html>
<head><title>Array
var <body>
<script> Example value The object. using Array
</script>"+str);
cars.concat)
document.write("The
The </html>
Maruti Output </body> str=var
"Maruti": Exampledtitle></head>
concat() Side
Syll. value cars with elements
concat) Ditterentiate
Scripting
w.e.f a
of comma.
method concat)
adem str can Language
["BMW", method
be between
is: separates
value combined
BMW, (MSBTE)
of
of concat)
"Audi", Array
Audi, str cach
is: by
and
The Array
by (Array,
document.write("The
Maruti Output</html> <head><title>Array
var <body>
Example</title></head>
var
<Iscript>"+str):is: "Maruti"}:
<body> <script> <html>
Example comma cancomma The object. MSBTE-Q. join0
str specify using
value cars join) Function
elements methods
to to
cars.join() = separate separate join)
of ["BMW",
"Audi", = a
character method join) 3(a), and
ions
-Neo str method can of
values. values, W-19, array String)
is: be
value also Pg.
BMVW other combined object
4
of Marks no.
but uses
of than Array (2-11)
Audi you
str a
a
<html > Example
New <head> Array.splice(start_index,
GQ. Syntax new It After BeforeOutput </htnl
<body>
<script>
Change:+enp): Dhiraj'
emp|document.
2]: = <soript> ><html> ExampleSimply.
sar <body<head> Client
is > write(After
document.
GQ
Syll elements used Change: emp number
Index
Using 2.1.7 Side
Write splice(0
method
Using Change: we
= <itle>
demic <itle> to
write(Before
WAP Soripting
the replace
at Ravi, (Ravi,"Lalit can
change Changing
the Ravi, hOw
Aray use Array Language
required/desired the Lalit, Lalit to
Example</title> of
year splice) delete_count, items Change:+emp+'<hr Example< change elements
Dhiraj., Shiva.
Shiva","Akash", Elements (MSBTE)
19-20)
method
of elements
an Akash.Akash, of
existing itle>
D5-16A) valuel,
index. an
with Prashant of array of
< Prashant <
an an (Array,
head>> Prashant]: head>
syntax value2, array array using Array
>"): Function
and by using index
value3,. ) removing
Tech-Neo Pu example. index number. and
numbe String)
and
Pa
inserting
(New function(parameterl,
Syntax 2.2.1 a GO. GQ. I GQ. I
GQ. I GQ Gllent
The definition.
The Function l The a Areadability.
increases
Function Function Function
makesmultiple
function. the times.makesthe task. FUNCTION2.2
Syll. code name,
JavaScript JavaScript Aexample. Side
body basic name(parameterl, parentheses example.
Describe with Describe
Describe How Define
Write seupuieangquage
w.ef to parameter2. followed to
be Function
Defining a the
academi function ofrulesparameters executed use the the
add and
function function one write
naming
of may by of termsarquments
terms
....include program return function function
is are parameter2, parentheses code
written is is calling scope (MSBTE)
a listed
parameterN) defined a
reusable; staternent
block to
function calling of the with
parameter easier a
inside variable
D5-16A) within. .. (). with of function function?syntax
(Array,
are parameterN) the as can it code with another
the each
similar names and and
parentheses function designedexample. with Function
small declaredbe arguments example.
function
to separated or
tions
h-Neo naming keyword, and
task to withoutan
) perform String)
is with with
in by onceand
a divided
into a
variable. the commas followed example.
stepsargument Pg.
function a no.
use it
specific (2-15)
and
by
(New myFunction
(message)
function<scipt ><head>
<body>
>Function
<title<html>
Example function. some We function
frstOutput
My </html> <script>
myFunction):
Syl. can <body > myFunction()
function
script>
<body>
<head><html> Consider
Example A Client
w.ef task. add 2.2.3
document. 2.2.2 invoked.
Function Side
mic arguments
Now, <itle>Function following
Scripting
Adding function");
write("'Mfirsty Wricing arguments
added
year simple Language
in an
Example "message"Arguments a a
-20) function, Example Function
function are
(MSBTE)
</ile> the
6A)
which </title> values
as generating
an
< are received (Array,
head> argument </head
used
message. Function
to > by
-Neo
ublica the
inhold and
myFunction)
adata function String)
to Pg
perform no
when
it
is
Example firstOutput
function myFunction("'My
> first
</script>
</body>
My </html
function'fi"r);stmyFunction(message)
myFunction("My
</seript>
</body>
(New </html> function <body>
<script> <head><html> document.write(message):
document.write(msg): let variable;completed.
function Local function.
is Local
The variables variables.Inside 2.2.4
Variables
Syll. msg
<title>Function variable variables
= the
w.e.f
message; can
it declared function, Scope
demin declared function");
be can
are of
access created only within Variable
Example the
outside be
to arguments
all when
accessed a
</title parts of JavaScript and
16A) the a
> of function from Arguments
(the
</head> function
script.
within function,
parameters)
starts,
that
ch the
and become
variable function.
ons
n-Neo deleted behave
local
is
a when as
global to
local
the the
(New Output </html></body > add(5.4);
</seript> function
add(a,b)<body>
<script ><head><html>
Example
document.write(ab); +function_name(parameter_values):Syntax An
Syll. 3
argument Calling 2.3.1indicated Denning local aNotfunction
firstMy
e Output Client
w.e.f Caling 2.3 that, Side
<itle>Function argument
ademic in Scripting
is a
a Calling the FUNCTION
parameters function CALLING
a A the
l function
calling value function of
above
Language
year
that a myFunction
functions Example</title> does program
19-20) is withFunction then
actually
passing not (MSBTE)
an function
D5-16A) execute function."msg"
argument with performs
when
</head> wil is
declaring or
be
it: a (Ar ay,
we local
Withoutexecuted. the
specified
need
variable Function
ublicatio
ech-Neo or to
calling an call and
and
Argument actions that String)
function.
a
functon.
with
"message", Pg.
no.
the also
(New
w.e.f
Syll. Step Following
Step1: Output</html>^nyFunction);
a firstMy
function </seript>
</body> myFunction
function (0<hody><head><html>
<script> Example Synt);ax pass We S
furnction_name(
2: 2.3.2 document. arguments canCalling the Note Sloe
Therefore,
the code After<head> First, steps <title>Function also function Scripting
that,
year input
cademic Calling write("'M y call a
for then, add callto tofunction in
tdisplaying
ag tag the the addabOveLanguage
we we<script>
with afterJavaScriptFunction function
function at
can have first the
19-20) onclick call the Example without programtime
to function"): (vi
the <title> tag without at
the call function from the of
(D5-16A) event.
information between values
function the tag </title> time function
an
HTML argument an
(Example: JavaScript and
lick="msg(0") from of 5
opening </head arguments; calling and
of write HTML function
JavaScript or 4
ations
ch-Neo data
function th e > passing
or
JavaScript document:
<head> calling.
sometimes declaration
on
bythe as
in an
its web the and
name function. arguments
HTML closing no
page.
need
in
to to
(New
(Before
Click)
Output
functioncall
Syll. > <input
</html</body ><body></script>
</head > function
msgU
<seript>
<title>Call
<head>
<html>
w.ef Example
UQ. Step :3 Client
alert("hello!
functionhtm type='button"
ademic Side
Write
a file, And, Scripting
D/TechNeo?%20Publications/function.htmlFile O Ravi JavaSeript JavaScript
year which
onclick='msg0" Somwanshi");
at
19-20) thLanguage
e
function calls end,
to
D5-16A) call the we (MSBTE)
</title> function JavaScript have
value='call
to
from save Function
(Array,
and
MSBTE function.
HTML HTMLfilethe
Tech-Ne function'/>
-Q.
1le).
W-19, and String)Pg.re
2 then
Marks
run
the 20)
(New square(num)
return s: let function
s
return let function
let let <script > <hunl>
<body>
<head><title> Example Step Step :3Step 2: Following
Step
= c b a funcson
call (After Client
Syll. = = =
num 4
w.e.f
a square(x); sum_of_
square(z);
+b+square(y); : 1: 2.3.3 sesiontm Side
Click)
* Finally, While
function-1
Calling steps
icyear num; and 1 square)and First,
sum_of_squares) Scripting
C;
squares(x, Function Function
return for DTechNeos20Publications/tunctionhpmi e
function-1
return write one Language
1/
function function-2 function
y, calling function-l
19-20) z) is two Calling (MSBTE)
function 2/ 2 // another executing:
5-16A) call function result calling
functions
different Another
result
ing
function back another Somwansh
relio Ra
page
says
This
from 1 function-2
and (Array,
code
calI.
after
22)
(New This
Output</htrml></body
</script> var <body> <html>
<script> The >Client
StringExample var
>
document.
write(str): ORSyntax
var
<title>
<head> GQ. GQ. GQ.
is str="This stringNamestringName string 1. characters. The
Syll. 2 1. means JavaScript
originalJavaScript
There 2.4 Side
string JavaScript A Enlist HowDefine
w.e.f literal By By string
literalBy are
that
String
STRING
Scripting
literal is string string
two
string any to
cademic string = = strings
if strings object createstring
"string 'string created is object waysdoesn't you string four Language
literal
literal': modify are are stringstring in
Example</title></head> value": value': to is is JavaScript.
year (using
using change.primitive zero for usedmethods in
create (MSBIE)
a storing JavaScript
D5-16A) either new string
string,
more
or to
represent
keyword) values.
Also, and in
single in youcharacters JavaScript with Function
(Array,and
JavaScript manipulating
will
quotes and syntax
always
manipulate
stringswritten and
or
double
quotes. get text.
Tech-Neo
ications inside example. String)
a are
new a
immutable. sequence Pg
quotes,
string. no.
(2-23)
The of
It
(New var <body> <html> Example Syntax vr The Client
indexOf(0 concatO charAt) Methods
String
Methods Created
A Outputdocument.writestri:
<iseript>
<ihtml >
<body> <seript> <head
charCodeAt) str stringName new 2. Side
Syll. variable. The values.
their Strings
as 2.4.1
=
character string > keyword By
functions new <title> Scripting
w.e.f string
are
cademic
Manipulate using String( =
objects
arrays. String new is Language
provide instance used object
Created Example< String(
year within
so to
various built-in a string create(using (MSBTE)
in strings.
It It specified
present Description
Itindex. It string
19-20)
provides
the provides provides provides the String
JavaScript using title> value instance new
D5-16A) given at ways functions
the instance" </head> keyword) (Array,
string the a the the to ):
specified of
position
combination Unicode access
char language.
must string Function
);
of index. value the be
a value contentS
and
used They
char of String)
two of present to are
value a manipulate
of not
orcharacter a
pres at
more string stored
the 24)
OcCurS. in It
(MSBTE)
side returns It It object.It Itletter It letter. It letter Itletter. Itindex.allows It on It on It
length.and replacement. It given if It given Itfrom Description
trims provides
splits provides converts converts converts converts is
used the used
is is
the used replaces match
a
searches searches provides
the
of on on the
the the that basis string string
a
the the us
to
basis
occurs.
lastgiven
string.white newly the abasis the to to to a the (Array,
6A) string the basis the the assign fetch of
fetch fetch given a specified and a and position.
primitive string the of specified string
given
of given given given the returns returns position Function
spacecreated into of the
specified
representing host?s host?s t he the
positive part specified string by
from substring value part part regular regular
ech-Neo
cations string string string string
of that its searching of and
array current current a
the the index. of of with regular position char
of as th e starting String)
into into into into the expression expression
left
array,
string the locale.
locale.
wellgiven the value
given given a
and particularuppercaseuppercase lowercaselowercase expression if Pg.
object. negativestring. It position specified a character no.
right then string string match present
in in (2-25)
a a
(New position.
indexor The A RaviOutput
Somwanshi
Digambar <html>
<body>
document.write(fulIName):
<seript> var middleName
var var var <script>
var <body<head>
> <html> sl.concat(s2); Syntax
Example Cilent
Syll. JavaScriptmethod 2.4.3
charAt() fullNamefmName
lastName firstName GQ. The
w.e.f method 2.4.2
JavaScript
concat() Side
Write
<title> Scripting
demic Retrieving = = =
String first =
fm
"Somwanshi": "Ravi the Joining
Name.concat(lastName): ="Digambar ": String use
String
Name.concat(middle Language
year charAt) ": of
Example</title> concat( a
a concat) String (MSBTE
19-20) Character
method str)
-16A) of
string method
returns from Name):
</head> (Array,
with concatenates
the
Given syntax Function
character
ch-Neo
Publi Position and
twor
o and
example joins String)
at
the P
given
strings.
226)
SylL
(New var <body>
<script ><head> <html >Example
string.slice(beginlndex,
GQ. endlndex)Syntax slice) 1.There
method Welcome
Welcome output</html></script>
str
string. Ifgiven The
Welcome,ScriTJavaopt </bodywrite(arr3);
document. arr3write(arr2):
vadocument.
>write("<br>):
document. Wsplit Var >"): Client
document.write("<br
r document.writearrl);
arr2
=
Write a are 2.4.6 Side
"HELLO <title> parameterJavaScript by =
three To To
beginIndex JavaSeript
JavaScrip,
small
str.split): Scripting
str.split('t",
the
String use
waysCopying t:
WORLD!": now
of
is
String for Language
Example</itle> negative, to
extracting Programming
slice) Programming replace t 2);
endlndex. a split
D5-16A)
19-20) slice(0 Substring by (MSBTE)
with
the nothing: by
example.
syntaxand a comma
position method part
<head> of Original &
a
is returns string: limit
counted string 2
the strings
cations
ch-Neo from parts return
the of
end string
of
the
from
document,writeln(subStr): var Clent
<lseript>
<body>
substring)
method 2.HELLOutput<ihtml> subStr
index)end Syntax
string.substring(start_index, Side
doeument.writeln(subStr): <head><title>
var <body>
var <script> <html> Example
GQ
(New
</script>
HELLOutput <html<body
> > accepts provided
indexes.
negative
This It The Scripting
=
subStr str works
Write JavaScript strslice(0,4):
= method
Syll. HELLO
similar index Language
= the
w.ef str.substring(0,4
String use doesn't and string
academic WORILD!: to
of (MSBTE)
Example substring) make thereturns
substring)
slice()
year ): any the
</title> new
19-20) with change method (Array,
method
sub
(D5-1641 < syntax in withstring. Function
head the fetch
> and
original a
example. difference the and
string St
string
that on
the
it basis
doesn't
0)
of
< syntax
/head>
and
exampie.
Number Syntax
Example (value); 2. LIe
document.write
e </body>
(NewSyll </html> </script>(typeofa)
write("<br/>);document.write("<br/>):
document.write("'<br>);
document.write(typeof
example2)
document. typeOf
write(Number(example3): Number(example):
i/check document.write(a): document.write(
document.write('<br/>")};
document. var <body> String<html>
var var <script>
var Example</title></head>
<head><title> GQ.
example2
"46" =example
aexample3 method value. Number0
number
In The Slde
=
Number(example2): Write case
Number) Scripting
= = the
returns the
"45.00003""44.09" provided
use Language
Not method
of
Number) a
Number string (MSBIE)
which
5-16A) 0) with cannot takes
(NaN)
syntax in (Array,
value. be a
converted string
and Function
example. paranmeter
ations
h-Neo and
to
a String)
number
and
returns Pg.
then no.
(2-33)
the the
Output
46 44.09
45.00003 Client
Syll. <body>
(New
w.e.f <head><html> Example 1 octal
numericinteger OR Syntax
base:number.toString
An ) anumber string
GQ. number.toString
[base) ) Side
and to toThe
needs be The This typeobject
Every string representation Themethod () 2.4.8
that toString
be Soripting
<title>String Write basevalues. usedtoString) toString)method toString)
representation
JavaScript
ademic the 16 as allows
Converting
It displayed returns Language
use hexadecimal. isbetween
is
a
string. method method
an object method
Example</title> toString) of you
year optional 2 as in a (MSBTE)
and is has theparses string to is Number
a convert
19-20) 36 text used specified
a representing a
with parameter.
specifying (like toString) its built-in
D5-16A) internally first to
syntax any (Array,
</head> in radix method String
HTML), argument, number
and The the method.
by (base). the Function
example. base base JavaScript specified type of
or and the
2 to when and
attempts value
JavaScript
ch-Neg Pw is use
binary, for Number String)
when
an into
representing object
needs to
PO
an Tts
base return object. Number
object String
8 J4)
is a
(Newwrite(str3);
document. write("'
varwrite(str2):
write("<br/>");
document.
document. var
document.write(strl
document.
<br>"); ); var <seript>
var <body><head>
<title> Example 2number string
String<html> 24 Output
24 </html></body
</script>
write("<br>"):
document. stJlcheck
document.write(typeof r)type0fwrite(num):
>document.write("<br/>";
write(typeof
document.
num) document. write(str):
document.write("<br>"); document. var <script>
Var Client
str3= str2 strl num
str num
Syll. Side
= = = =F
w.e.f
num.toString(8);
num.toString(2);num.toString(): new num.toString); =
24: Soripting
academ Vumberfl0):
Language
Example</title><
head>
7
base-8, base-2, / (MSBTE)
-16A)
convert convert
(Array,
10 10
value value Function
ons
-Neo in in
octal binary and
String)
Pg
no.
(2-35)
Client
(New var<seript>
var <body> A 121010 10 document.write(str4):
Output <html <script>
<body>
> write("<br
document.
var >;
ower+<br>"):
document.write(
Lower <head><html> iGQ.Example string. string. Syntax
toLowerCase();
toUpperCase(): str4
lower str Side
Syll. =
letters. lowercase
uppercase letters. The
ThetoLowerCase() 2.4.9
example Write = Soripting
wef "HELLO=
<title> JavaScript JavaScript num.toString(
str.toLowerCase):
demic the Changing
Sring Language
WORLD!": use
String String
year Example</title>< toLowerCase) of and
the
l6};
toUpperCase()
toLowerCase()
toUpperCase
(MSBTE)
19-20) Case base-l6,
/
D5-16A) of
and String convert (Array,
head> method method ()
touUpperCase
method Function
10
ech-tNe a returns returns value
and
in
with 0 the the String)
syntax
given given hexadecimal P9
string string
andI
in in
(Newdocument.write(unicode):
</html></script>
</body> var <script
var <title>String
><head><html> GO.Example
<body>
unicode str string.charCodeAt(index) Syntax 1. AUpper LowerOutput</htnl>
</boly> document, var
</script> Cliern
Syl. it Itstringthe Unicode
The charCodeAt)
The upper =
=
Write is
returns 2.4.10 Case: world!
Case:
hello
"HELLO greater
we.f = indexJavaScript
str.charCodeAt(l): write("Upper
acade the NaN number value HELLO lower.toUpperCase);
WORLD!": use than charCodeAt(),
fromCharCode ()
Finding
or the if of
Example</title>
<head> of
equal starts
string
a WORLD! (MSBTE)
nguage
charCodeAt() character Case;"+
given a
to charCodeAt)
from Unicode
number
the index is upper);
5-16A) length 0 at
with and the
goesspecific
of
syntax of a (Array,
method
the to character
-Neo
tions and string.either a n-1, index Function
example. where is
inused
negative a and
string.
n
is to String)
the find
number or Pg.
length
out no
of the (2-377)
Client Side Scripting Language (MSBTE) (Array, Function and Strin
Output
69
2. fromCharCode 0
Unicode
JavaSeript fromCharCode() method is used to convert the
values intocharacters.
specified
The fromCharCode (0 method returns a string created from the
sequence of UTF-16 code units.
Syntax
string.fromCharCode (number)
Example
GQ. Write the use of from CharCode) with syntax and example.
<html>
<head> <title> String Example</title></head>
<body>
<seript>
let str = String.from CharCode(72,69, 76, 76, 79);
document.write(str);
</script>
</body>
</html >
Output
HELLO
Chapter Ends...