0% found this document useful (0 votes)
14 views17 pages

4dwduct: Jaa Seripl

The document provides an overview of JavaScript, covering key concepts such as variable declaration, data types, functions, and control structures. It explains how to declare variables, use functions, and implement conditional statements and loops. Additionally, it discusses arrays, objects, and methods, emphasizing their roles in JavaScript programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views17 pages

4dwduct: Jaa Seripl

The document provides an overview of JavaScript, covering key concepts such as variable declaration, data types, functions, and control structures. It explains how to declare variables, use functions, and implement conditional statements and loops. Additionally, it discusses arrays, objects, and methods, emphasizing their roles in JavaScript programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

4dwduct orm ia JaaSeripl

Peiniion:Ih Java.Snisl', is fuc Hons au riltn in Comnand


heitie tauk .

an adior. tn Jaonseript , cah dlalimunt nualy


unc otth a uni tolon l:).
to the

3. ky Typu shlnundsstakmerts
Deelaalien veluu
a Vaiebe Vatoblu that holdi data
Pahee : Decloe

Let x l0j
Cet noMe Jokn

Let -30;
b. Aulgyuand stalmerk
a value to a fuviauly dalaud vaiadke
Synian :
x-0,
Examplkwatlane
: "Bob';
qe 35;
Dclaustion and Call stabmenli
CFunclion invotu hum
tock (funation)and
fuhe : Daine suuate code
to treute' dhú Loqic

tundien qedt()
Cengale.logl'Hello, Norl4");

kranfle
tuntion add Cx,y)t

Console loqloutt) ;
(, thu, slu )
d. Condi tienal slatnunt gyass llat baud on Condihon
Coruol tle fos o gso
Pufeu i

tlan to' ),
Cendoler loyl"x
Losping staknusda Cfos, wile, Do bohtle)

forllet i= 0; (esttt) 1
tonole loyl:);
tor let izo, ie numbu. lngth ; itt)
Corsol log lnum buali3);
4. Rlun state nunt

funtien sun C3,4)

Taan nursber number

Ld sult squaz (5;


|4 kxpruien Ghatenune yale, Thue
thab sult in a
inition : Ereut epution
txpresiony
Synla-ztl;
Exomple :
I,t tolal 5*4;
5.
dava Senipt Etcuilien flow
diynchtonow Breution Java Serpt can alko handle aynhuora
opations leg , AI calla) though callack fuitions, frormitu,

set Tieoud (tuncton)


}, 000);

|e numbe Dt,), 3, 4, 5J;


tor lld i- o; ienunbus lngti it1)

a. Commenta in Jauo Senipl


Commerd ou an wurtial pat any calebau, pmovtding
erplanalina, hotu ,or the denloper and
onynn andlng tlu cade'
Single kin Comurst
u wd lo add brieh noter on ezplaraha
A Single-Line Commer stau oith Lo bnd
a speie lie o
Code. The cornment
o slaihu (n).
cingl Line Cormunl
b. Mult Lin Commet

ue maku will Joe conidud fat the carmnunt and

This is a
Multi- ki Cormnunt
Bhat shons Mulb lns

B. Vatia bles in JavaSeript efamud


Vaciabler ae that can b
ued to utoe dab
sript, they au
A Java
manípulad 'thuoghoad thu pngam
andDeclaualion Vatiables thee
e one of the
in Java Seript , we
a vaciale
To declae let ,0T Cend.
i Vat,

Vatialble lane = Valve;


lel
vatiabeNanu - valua;
Cent Yala
VatabeNlane
Vat

nane= John'
let
Cont pi - 3-14;
Naciable) Serd
b. as (fundien -So pad Vauable in Java

Sqnlar: Val name Aice";


hurcion get)2
-"Hello, +name;
Vat
Corval log lmuunge);
gueetl);
conole lag (wsege); au Hock
- Steped )
Vatia bl deelau Uaiables lhat
C. Jt (stock to
a nodun
t
culy brace ?s
donold by

true)
let city "London'
centole.loglihy);

Cenalant Vatiable) Voloes Cannt


d. Conut (( contant Vauabe, nhoL
Centt á wed to declae
thy au inttalgod.
be meardhned ajtu
Syntax : Cont yaloy [ "J;
4 Aats Typo in Jhvasripl
n Java &eipt, dala tyru cakgeuud into o main guod
Irimthe Typu and alan- Prinlhoe Tigu
a Prinnili Dala Typu JavaSeript. They
bauc typu în
QL tae nt imulalble , Theee type tnelude
Tpreunt 4ingle val and au
ctue uud to sjpund tet
Shing: ASaqunca d chata
I

bidk inkqu ord Hoaling -polrt numbu


3 unaber : lnt
Brarle let score - 98;
value cithu twe or ple.
Beleoa : Reprent a layical
3 true lfole
Erampe: let á Avai lable -
ben dedlad bot nd yot
A youiabe thal has
4Unelefinedi
avale the valoe ndafined

inkakional abenu d any vale os


5 Nulli Repreent tlu u no t ame a

= null;
e d to
ond iuubble vale prinaaily
6. Symbol: A urigue
proputy key to objpiti.
add unique
1- Biq Tnt : A type that con
Tepreend integua with arbtlary
nunbuy thát
extecd tae Aleumbs type's imi.
Czomple i tet lasge Nleurmbu 123456 189 (o 11 254 50099
94364ny
b. Nan- Printtive Data Types
Non- Primihye data types, alo called rojunu typu, ae pme
conplea than prindhve typ
shings , and valoes an be ony dalatyp

type of obyecd wed o atore a collekhon


A special
| fi may : clenunt eally odund.
Ezample : led nuntbes [t3,3,4J;
: unctien it a bock of code degned o
3. Funetien conedeud a
paulicula tack, and st ci alo
pefom o
non- piaiho r
funeton get Cnana)t
Exampl ehun "Hello' t name;
'Conoler log lgut ('Aie' ));
to eprent dat and tuj
4 Dati lled
Eramjle: let cuent Dattnew Dat()
cstent tene hew tim C):
let
Corok log ltuund DatelTina);
5.

Aryraalow in Jovato Scipt a ed to


atoe colleciom
pnd ghouy? auliple luu int o sihgle verta
oteen tack alneot
Featuu
1Tndexed
Elemenh
a numeit inles
: Eoch clement in
an aTay
Erample : let colorg staing yeonn O.
'nd"',
Corvale log lo lovg lo3) ;"n, Hu" J;
Dynami Sizing: Aroy, in Jaua &ript can guk
shint n sie dypanteally; you don't ned to or
ied size delau o
Exomple . let nunou -Et, 2,3];
conale. ig lnunbes);
3. Heluogant on Elemert : Amay can hold valon dift
data typs
Bxanmple i let mized -[43, "belo', toe];
contole taglri scd );
elanunt in en anruy dindly
4 Mutable : Vas can alhy
Esanple el Aott ['apl, " banana' chrry
Cemm on

Addag &letenda:
puskt) : hdds an elenund to the end of tu auay
let au Et, :]; unhulf (): Ackd4 lenud io begisag
ar undhat Co),
Conuala loglac); Conso le . log larr);

popl):Rrnoya th lat elenund of e acay.


aTT þop);
lenunl
ghif} C : Remove tle
anT ahyto;
(onole toglarm);
8- Anding t leniend:
.indea C); pehuun, te den o th kret concuunad
of an lement
Retun - 4 not toun
let trtt -I'aple," boanana ', "ebery'd;
Centole -log lhuri, ndez 0f (*bonana' ));
4: Ikeraliy Through Azaye:
for Clet i co; i< huil leng th ; itt)!
Congole log ltroil [i D)
Ukng foreachC1;
5
tlemn
· slicet): Crat a
ahatlow cogy a portion an
lt new fruih fuih
6
Cortole: loy Cnew trotl);atce lo,a);
ihnsgnig tnank
"mapl): (reat a nw Qxay dy
let
humie ll, 9,3 J;
dianaorning tach elemd

Let aqucsed - nums- Map lrum)


corole ly l quaud ); numum );
.Piltu 0; Geat a new
pat a teel axey containing tlenunt hat
let nerw l,2, 3, 4,5J;
let eocn= num
lteulnam)=nun/"& == 0);
contole· loglun );
Index: e the bTack ef nofahon th taa elenui indeu
let aninal -I'dog', "cot ', "dphant

c
Padezirg, but ou com achavt in wing cudons logi
lad aninaloninal lergth.1 J;
lat
Molhd'
Java
angional Aa wttktn drTay, knosn a
mulfi-
Soript Sont armo
Examfle i et natix I[t, 2,3),
I+5,43,
[1, 8,9J;,
J;

6 Shing in Java Stipl


Sfing au sequnw of chancke und to sture and manijht
at They ae encloud in single quotes ( , dasble quol (
B bhctbtks () for nplati (skraly

1 Shing Declaalion:
e double qoola :
let nan "Tohn";

shiny bpubu:
: tehuns tu nunbu of charackus io a ching.
. length
tel meag = Java Scripl";
3 Coruneon Sting
Conveat the sbing to upiucau
obpperCau (:
coruele. log l( "be lo oto Uper laul );
funclienu in Java Scaipt
tuncton au veuable locks of code dagod to puform
tauks- Thes tate npud, prec it, and oun an ouhet
heitie
key Fealu of funtion
1. Funclion Declaation :
funtien qpet Cnamu )e
eun 'Hello, non y.;
Cend- log [gnet ("Alie );
8. Parants and Argursunt:
to the furhon when it i cal
Ayuraent i lalues paad
3. Fancions bxreuion : lable:
a funchon to a var
add- tuneton Ca,b )N
Cot
Tetn atb,

Centadle. lag ladl (a,3);


Ansuw Functios (es6 +);
4.

5 Dfault Poranulas

qAut Chone fvat')2


Punchon
yeturn

Centale .log lqret () );


t. Methocdh in Javaceipl
belong to obet ond au wed
Me thads au funhona that dala
pfpom operabuns on okyet
to
key Fahueu Methad
TShing Metiadi soulae(1, and lecel ) au
toUneu Caul), tolo
"Mefhod lite
let tt Java Sert pt";
Conaole. lag (sh- tuyper Cau 0);
t, popl)4 flka()
"Aray hav ette dy tekk puh
tet nunbus -lit,3);
nenbu puhl4)
tenale - toq (numbur);

.(ouhum nethoe ton be added b objet


let car l
brand :'Toyota';
stat:Punion)e
brandjs ptuing!':
Tehun t{ thiar

Corule. log (at, stat)),


Ubjel au Collechiom kag- valur pa thal allo yw to stae
Telated data and nMehodh
key feates
car-make "Toyeta',nodel:"Cafmryyea; 2020y;
let
Dot notaton:

3
Cais color "Red';

tondole loq la);


4 Ddliling Pgerhe:
delete cat colo;
Contole log la);
Dectytens in JaSript batcd
||0. allow you to estcate code
Declgien making Conhut
on tondiho.
key Conhct:

log l"ou can vote i)


Conade
ele i staknnl
let mat 45;

Contole dog l'Grade :A


Conzole log ('arade 8)
Conuole log l'Grad ic");

Swileh day)
Cae

Conale.la (*Monday "),


breat:

Loopsalloo to ezecate a kock of code epeakdty

.Lloed ohen tu usaber of Herahon Fnoun.

contol tog (i);


Jhile log
a the (onditin s true.
"Executu ony
kohile Cics)l
tenole toy (i;
3 do ohtle lop:
'E1ecula at teat trnLe , thun checks the condihon.

3pohile (i<s);
4 tor..of Loop:
ovu terable ohiul ike arnayn.
"Jkrabs
I'aple ". "banans', "chenyJ
let truitk
for Clet hit &tuit ){
contole

5.
fon..in koop:

(let y in Cat)e
fon
cordelog(ey,carltq)

You might also like