0% found this document useful (0 votes)
4 views

JS Part-1

java script

Uploaded by

Akansha S
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

JS Part-1

java script

Uploaded by

Akansha S
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Vava

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

olloisc the yndaz and ctneucture


cinu the

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

Applicatibn Createinterac tive ebeitos


l4is. (Lsed
-for
4ismainlt
mainlg
Cliend -cde.velidation
Dynamie
dateand time
oYalayiog
Diaplauinapeputup
oindou and dialg box

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)

<scrint' Ayne =text javasaript)


KLscrint)
<Lbody)lai

<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'

eShot on realme C53 108MP 2023 1204 18:38


PAGE NO.:
DATE:

JS Variable.
Variables re
VOriablp
Value
biilding
Contaoer
block
that Stores

Rales
These Casp Sensitive
Can Anly begin Loter Underccbre (" )

LetHer underccore let


characten
Reservd be Variable

Variables Aynanically
decidec
Gohe

There Sfare there


de4ine the Variable,
in three

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

that block SCeped


Syntax
Let Varibte. name Naue

-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

Sespe Function GCapad Block cceped lock ccoped


Updatien Mutable Mutabe Immtable

Redeclaration Cana be Cannotbe t cannat be


redeclared reolared

Pro csabL5ah Csa015(cse)


Origin.a
Suppart Supponte Not Suppanted
eoeo the c d t

broueser booese 3brotueeer


Therharea tusatypes varinhlea in2Lds:
OLoca/ariablei 1tnis. cor lared inicide block
Hunckonlti is nccessibleteithinthe
functien block ealy
halta

Alan funotion abe)s


l loca variable

<Lcerint)
(Globa is acceasihle cor any
funetien wariable ie de cloged oetcide the
funeion declar ed toith aoindao e.bject
<serint )
PAGE NO.

DATE:

docume nt turite Inldata)


-funiotioo.
aU calting
<LceniFt)
US Dattypes i
USprauLdesdifferent datatypes nto held
different type
Calco calle
US
toszely
dyna micaty
lupza) Gcripting
ypd
tanguage
The re tuoo data tupes in
Primítivp karcla ta type
Alen - primitivereference Complex) cla toa tupe

Primi tive Datotyae.


Steing ) The prede fined datoatyne
datatynei. prauided by
knouon as primitive da ta typei
language asibuilt inada tn tynes
Stringrepresentea Seajuence nokeharaetor

Apna Callg
1

Cencale.log CfullName ): Apna College


Number i represent ntemenic 2alee

Canssle. log lage)


3. Boelean epesent baolean waleeAethe2 dacee
Dr falce
fcPolloA) = ruLe
Console log Cisfolloo) tree
PAGE NO.
DATE:

Unde fin ed.


represents tnde fined valeLO
Con.cele elag C) LLndefined
5. N t ubtence of jeet
repreents C.e a no valeat allL

tbject

Bight Biglnt ("123")


Can
123n

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:

Cantale alog (student)

Dame:

Console log Cstudent " rH name "

Rah) kumar
To acCesSShe particlas key
bbË ke
ebj l'kgl
Student epdlatethe vale &
["ag"student" age"]+l

Consale l6g student "ag ")


studen[" RahuShatma"
Consle
le.lag ustudent'name ", Rahu iS harma
AJS Comments i
Pant bohich PXeceuted

isatingte lene
eneComme nt
meelti Line Cemment
PAGE NO. :
DATE:II

JSOpe rotors:
LS operators ymbals that Cre

perfozm Aperatieh.s. spezoncds

There
Arithmetic
re
fallausing
Operator
ypesia 6perators

Compa.ricon ( Relaional) onenators


3. Bitoise Operators
Cogica<peratars
5. AcsiFnmant opeanton.a
Speeral Dnenators
Arithmetic Operato
Onprator Deerigtin
+ Addition
Sebtractien
Multiplieation
Oivicign
Modulu(Remainder)
Increment
Decrement
Exponendiatian

SubtaacionmultinlicatianDivision
Addition

3
Conscle . log (a)
PAGE NO.:
DATE: I

lot a 5
lot

Consele.log "a "a"b- " b)


Cons ele. log C atb= t1

a- b);
("axba
( a b=a' b)

Consale. log "ita t ta) +talG

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)

Centele.leg pVen num ber.k

Canscle. tog "nttm"ntmSadd


Add nmber."
D/P
nembon
PAGE NO.
DATE

WS if- elco ctatement


14 pvaleatos the Cooteot teohether
true false
fCconition )

ges25

Concle log ouAreieligibla to wo te,

Consele Leg You are not


eligihle. to

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)$

Con sele..log ("tis. z0ro ");L


Case
Consele

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

the Sinplifie4 enorator bf if/else


Syntaz
Condition 2 valLe valuo f falee

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

far (var of itrable.chiectName) i

Let
Apna Callegs ))

Cansale log
8

Lan tale .lsgtrig

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

doceme nd.orite le2)


</serept)

This method
Luadirg trailing ahitaspac
tom
from 4he string
<seript)
java.scrint trim " javaserin! tr

doetmento knite lsa)sk


</scrint)

You might also like