JS Part-1
JS Part-1
Senipt
PAGE NO.:
DATE:
what ic davascript
dava Senipt 2?
Sis light tieight cbiect -oriented prngramning
Languagewhich
for Sevoral webcite
Geripting the otbpagea
is
inter preted fut-4ledged (camplete
develenzd) pragramami
pragranmingng anguag +hat enable
dynamicinteractivityAdocLumaa
to
HIML
to cliend -cide dyna mic pagee
Campilad language bet
Hranslated langag
pnagraningangunge
Sttured programming longage
language uehere
centain Cimplicitly Cast ldepending
the eperlian)
3. chiecteorientea praganning languag
pretotinegratherthan Clacsee
that ing
for inheritance
y. Light acigkteg. interFratrd language
5. 14
Severl
hngung
ANer the
4he
Contta!
praucder gaod
PAGE NO.:
DATE: I
Lolocksnh eto1
Dicplagihg
Hoo to adduS2
the Coce
provides 3 places to put
end
htm
Betwecn
btm
Betaeen the bendtagof
Ln s file externa javn.acnipt)
Code betaseen
htm)
<htm1)
<bodu) <Ibady)
(seript type
alert lHello World1)
<Iseript)
dalaated"): ¾ello
msg funcinlert
messnge
exteneian bys
be
cingle htm Cevera
re-usability be Can
becaue Code provide
bed lm nd file externa
S Crpate we
Externa
3.
' </foam)
onclick= "ek Nalue buton <input
<foxm)
shady'
<Iheed)
World
" Holo alert
C"
jauascriFt" funcien
raext Aune seriFt <
<hend)
head between <html)
the Code
DATE:
NO. PAGE
PAGE MO.:
DATE:
index htm!
<html
<head)
<ceriFt tyne C'me scnge-j)
</seriFt)
</head)
Cbody>
<form)
"buton eliek
<ioput type
</am)
<Abody'
JS Variable.
Variables re
VOriablp
Value
biilding
Contaoer
block
that Stores
Rales
These Casp Sensitive
Can Anly begin Loter Underccbre (" )
Variables Aynanically
decidec
Gohe
AonatConc+
b antable Can be re -declared and
tupdate
ic teeed to declare ariable that
unctien ccepea variable declaxed inside afun
Syntax are Hun sconed and canno t be
VariableName otttete tht
PAGE NO.:
DATE: / /
Var a44 60
canzele. Iog la
Cannot be
he declored but be
ot Variables
Ddate declare Variablec
-86
Consee
thgloge
Const; Vaiable bere-de claredor atepdatod
ESG intradacod -the Con st knysord tode ine
DeVariablo
Const
concele.leqg.ag)
to Censtant
Oncanglt TypcErrorMssignment
Vapiable
PAGE NO.
DATE :
Prapeety Var
<Lcerint)
(Globa is acceasihle cor any
funetien wariable ie de cloged oetcide the
funeion declar ed toith aoindao e.bject
<serint )
PAGE NO.
DATE:
Apna Callg
1
tbject
Let
4Symb ("Hlla"); O/P
SymbelCHella;)
Non- Primiiue
Th that are indorivd
datayne
data types he
frÏm primitive
o language knoten
ntn- nrimilive datatype
9ure fundam2ntal datastrctuxe
to Store Collertiun data
Coneist key ivalue paits and be
criated uaingcunt
Const student
" Rah kumar"
is P o ! t r e
PAGE NO.:
DATE:
Dame:
Rah) kumar
To acCesSShe particlas key
bbË ke
ebj l'kgl
Student epdlatethe vale &
["ag"student" age"]+l
isatingte lene
eneComme nt
meelti Line Cemment
PAGE NO. :
DATE:II
JSOpe rotors:
LS operators ymbals that Cre
There
Arithmetic
re
fallausing
Operator
ypesia 6perators
SubtaacionmultinlicatianDivision
Addition
3
Conscle . log (a)
PAGE NO.:
DATE: I
lot a 5
lot
a- b);
("axba
( a b=a' b)
Cons ole
PAGE NO.
DATE:
4ssianment Operatnrs :
Oneratarc
tr= Asaign. assig0
additian
. =
le Q 5
Let
Consele log ("a4=4-",at=y): !
Compacican Onerathns.
Operator name
Eaualitt aperator
Inequaliy dnerator
Strict eaiality enerator
Sirict in2auality eneratr
Greater 4han epeaatn
Greater than eaua! operator
than orator
tha
Cond1
Reclb)Res(1) Conda Cond1
NOT
Lagical
AD
Deseriptien Operaier
oga==2ba=b);
lL consele.
b=
3 tet
(assb"==
4 b) lagConsale.
String
ber nem b"5": Let
5 = alet
ab)
false acsb Cab"as
b); ale.logConcele
b
a5 Let
Cxample
DATE:
MO. : PAGE
T
Conda Cond
A
shif inht
<<
X0R
NOT
OR
Bituoicesni
AND be
Detcriptien Operatnr
Apereto Bituoise bits 3a
6perands US
Operators BHsise
DATE :
HO. PAGE
PAGE N0.:
DATE:
Conditien a Statomants In
Dxpcietecpeciblockc
Code.
based Condilie0s.
There Severa!motho ds hat Can be
to perfaam Cond itiona!Btatemeats
Statemeot 0
if-else state me0t
Suaith Ctatem2At
peratar
US f Ctate ment
to èvaluate
he
particular conditian
Conditon held.s trueithe
Code black ekeonded assocatod
if Cconditien)
if Cneem ==2 0)
ges25
0/P&
You VAtein
eliaibls to
US olce
Ovaluao. the ConteOt onlg Pxpres.cion
from exprecciensanl
ifCcond1)
3elee iflconda)s
3etee fCcond 3)
2elee fCcond4)s
3elseS
3
PAGE NO.:
DATE:I
Conct Dtem=0
1fCoem )0)S ispasitiue
number
Cancelp. lag ( Given
3olse if (num<o) negative,"):
Canscle. tog (" Givn
Cansele.lag C" Given DLmber
3
CiveoinumbersLrO
SuaitchStotement
14 is to execucle Cade
multinle Lxhressons
break 0c de fautt1
keyussd Laptianal).
Suntax
Soidch (expressi bn) asn
Case value
Statementl
break
Valueai
break
Cse va lue N:
statemknt N
break
de fautt
/stat ement
3
PAGE NO.
DATE
Suoitch(i)$
breakn
le.lag
deaelt
niscle slog(iis greater
qreater than a")
is greater thana
Ter00r
The
Opprator
mark "conditiena!" Oprnatns "
Rherands tornary Operatoz thatnhas thxee
fnction Mmark
Not mrks 95
ot e s l l m o
fenetion remankU
.solelog (r0ul4)
remark U
PAGE NO.:
DATE
Loaps in dSA
Loops
The Lnaps
4oratthepieco
forahi lesdo
forhiledo uohile
orin
ode
waing
tusing
losns.
makes he Compace
Cade
ismastley tsed io
Qre
for loop
14teate sothe element farthe Cixednumber
time.
Synda
Sor (initiaizatoo Conditien 3 incren &nt)
code to be executed
<seriFt)ad
Concele
<lseript)
Sem |5
S uahile
the elemont for o thel infinite
number 4imos,
PAGE NO.
TAC DATE 1
Synta
Ahile(conditien)
Code be executed
Kscript
ehile Cikl5)
13
Contelelag (i+"<by/) "),
itt
<lscrin!)
do ehile
itenates +he elementc for Lhe infinite Dumber
times Like hile
But Code at leat teehethe
condiioo true false
Code to be erecuted
3nohile condiLibn)
do
Consele Q3
log
3 tahile (is25): a5
</Seript)
PAGE NO.:
DATE:
for..bf lonp
itenate he Valuesean Lteabla
Set
abiect llike
statemeots agLmentt chieak
coreachvaus
cte ),executing
the
makes to Losp thaugh 4he
elemens
Let
Apna Callegs ))
Cansale log
8
shring
PAGE NO.:
DATE
5. for.in loop
L&ed to itemateL tho
obiect
Syntax
for CKeyin itonableebiertName)
Lot stLde nt
Rah kLmar
R45
isPas truLO
3
for let keyin student
3
shden)
for llet key
Cantalelot
Valuee Rahu kuman
value = 20 12
Value = H.5
ValueF truQ
true
indiceci String
Lstr.laagth)'
a; Lonsole
log
egeisa apnacall C-9consE
astn
preperty length -inbuil! uzing
astring lenghh
LenglFindingthe
Litezal) string Siring ctringname
D Var
kysdd)
skiact
ahiect
string By
eaing
value iring Gtringname
Var
gnlay
tding reated string
doulele By
iteral
slring
Create
ciogle
4ycLetea double
oithin character 70r0 Contain
nce character
Ceprekents sbject
hat 4 Strings
in iS
: JS
DATE
NO.: PAGE
PAGE HO.:
DATE: |
Stning Methods in d
are bilt- infunctioo to manipu la te
Thece
ring
Thic methocd etuzns the giLnString
<seript) UAVASCRIPT
sl=ulava Scrin: "
doceLmenttrite ls
<lserig )
Str, tolasen Case
This nethad eturns the given ctning
le Hors
D/P!
<seript
java scriptt
This method
Luadirg trailing ahitaspac
tom
from 4he string
<seript)
java.scrint trim " javaserin! tr