0% found this document useful (0 votes)
30 views21 pages

Adobe Scan Aug 01, 2024

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)
30 views21 pages

Adobe Scan Aug 01, 2024

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

Intxaduction oE Tauagcoipt

Defioe
Sava Gcai pt ie a papulacr lightLeight and
open Gausceclient side scaiptinglangungs
Guppontedbyall baocses

Saua Gcoipt ns Gt chent side end) thoaugh


brocuSex uithaut Sending message back
to the GerNe

because
because itit canbe
It is Gcaipling language
Ged alonq Loitb ancthe ragnamming lanquage
-Usually sotlare developers ueed paoqpxomming
langunges Rkec C*,ava, ete
-On the othen hánd web develoerg uáed

Oto awild dynamic ueb page


Lo to Createinteractive femmsS
(3) to aespond to events
Bto vaidate data being inpatted bu the user
(6) to contdl boouser data

-Jova Gczipt io nat purlyproananrning


ply
osather it is an inteapneted lanqu
language
hence,javascipt dont need compilation
Na
Java Gcaipt is designed in
in Such a wway that
6ATE

ue can integaeBed ke Communicate ith oth


pogramning languages
-Java Sciot ig also used in many gamea
develapmenks & r applicatian development

DiYenence betuseen Taua Re TavaScipt

Joth re Completely different languag es aith


eSpect to concept ond design.
2Houseue, Syntax in bath languages is Gimila
a Taua is pousexful progamming language ke
and Iasascaipt ia not ally eak
med paagramming lanquage,nathe it is an
intexpaeted Gcalping language
A Iavo paagams need campilation & TavaScaipt
pmaarams. dant need compilatian.

are executed in /aua


competible applicatian & Tauascipt pragasmá
in all broae
Clieck (wher)
[Link]

|3auacaip Souabcaipt
Code io dinectl
Sent Lclienk
cude is Cxecukcd
at dienk Crd

pasqram.
Iauascaipt ieatuaes.
JTS 9 a light ceight apen 9once,intenpreted
acaiphing language
language Ifke
java.
Case Sensitye

A19 pnouides pae-defined cbiects Such as


sindoJS,dacument, math,elc.

SS is designed eox aeh hased applicaion.


TS is complementazy to
t. h Can be integzeted
aith jova
PAGE No

DATE

ITS iG complementa to e can be integele


ith HTML

Open Souce Cacss platfem

language
ntage o Tauaâcaipti
Aduankage
oisaduantage
nGecunity Na the 35 code ixecked on clhe
oncliert
endit Can be exploiLed.

aT9 cannot be ued Ra hiah secuib


Lnetucking applicati on
aTs does nt oide anmultiteading.

g The autput 39 con be paediched

easilg
TauaGcaiot editooG

TOE - Webstox m Cpaid)


Netbeans (fee)

Vious
Viauo Gtudio (vs) Code
lightweighteditors -
2 Roeel
Caoas (hee)
AAorm aee)
Natepad (aee)
Ntt (beel
Gublinne Lxee)
"Frst Jaunscipt pNagTam

<HIML
<Head >
<Ute> First TS mogram <Ititle>
</hea d>
Sbody
<Sriot language =java Gcaipt
[Link]("Hello wozld
<lacipt
<lbodu>
Khtm>

et IS pzaazam
Hello wold

Seaipt taq
-TS prcaram is always wzitHen in <sript> tag
-<Scoipt> taq can be Luzitten in either <head>
Section or sbod4> section o HIrIL roqxam.
KScaipt> tag în
<hea d> Sectian shody Sectin
<head>
<hody>
<Script> <scoipt>
g am;
</scipt> <Jsipt
<lhead>
KIbody>
has lallousinq
ollauuing Lwo acbLakes

a language languageataibute is always set


lo "iavascaipk".

9 ype type attaibute is set to "textliawascoigk:


The type athibate tells the baousen
that the Gcipt is uaitten in plane text
l follaG the javascaipt faamat

Data ypes in TavaGcaipt


Tbene

aimiiNe data tpes

BNon-pirnitive data types.


A aimitihe Dota TupeG

asaina- This data tupe is used to Gtore


Stainq G gequence ot chaaacters
ex Na st1= "Hello'

2Numbex Nomber data tpe ig U9ed to store


int & loat Nalues
Gtore either true
38oolean Tt je sed to
Ralse

undeined Tt eprebents undeined value


ascigned.
ex. Na e= undeioed

absence ot Nalue.
S nullnull indicates
ge = null

eNonpimitiue data types a


lcbject obiect epresente the instance throuah
which Can acceeS membeYS.
Na e-iname ="Payal"name = chelaz"i

almay Agsa represents group a Simila


Nalues.
ex Naz y=lI0,20, 3a, 40, 50i
pagam Tauacnipt Second i9This
Second
Qutput
<lhtml
slbody
<hody
<lhead
<lscaipt>
type="Ltljauascaipt"
Scaipt Sac=l
=aasczipt" language SScaipl
pogram Second <title>
</Ltle>
<head
<htmlZ
Code HTML
me
Aheaaam
thi to &Save [Link]
pnagram Tavasaip
secand (Thisis
[Link]
CadeiIavaScipk
alelsapta code açealel
PAGE NO

DATE

Naluea and jaaiables..

Tava acaipt isa dynamie or locsely typed


languae because qiuen Can toae
ariable
any data -type at an4time
hald ualue of any

Nar keyuord is use to Specify the ua


Excmples -
To etone int value - eq wat a=l0
a) To stere Rloat value -eg. Ja b 3.14,
3) TO Gtore char Nalue - eg c
(4)To store gtoing volue - eg. d="Thane"
c) To stare boolean Nalue- eg. e= toue,
() To store null walue - eq Naz =null
( To stone chËect value- eg Na ctudent =

Rname"Paya
Inome:"chelaz

-Caiect name

Taua Gcaipt (3S) ObËect is a collectian o


named values and 4his yalues are called as
hraperties cf cbiect.

-Caeneolls ainitive (in-built) data-tupe vaiables


store Only ane Nalue at a [Link] the athe
hand TG_cbiect
abiect can stoe Nalues of difenent
data-types.
PAGE
DATE

-A eb page containS Nazious objecis Such


0s doCument, Loindoc, Rom button etc.
Lach abiect hauld be uniguely identifred
by a name or Id in eb pages. to distinguish
eb
betueen them.

Oaject propeties methods

swdent ahudentano=12Chsdent display,


aAudentoamae"Rayal'
[Link]'shelo

ropeaties
-Phrapeies nhing bat the values associo
Led uith that cbject

-Evey ahject has aun set ct praperties.


eg windau,obect has papesties (ike width
height, backgraund colon etc.
Genenallg prapes ties oitten as key:value
pai.

narme:"Paal"
-Metheds of cbiect.

-Method is of instuckions pelommed.


a set
the cbËect hen it eceivesa message.
Sgnta [Link]
eg. [Link]
Det sntas
-Dot Suntaxis used to access he propeie
Land methods of theabiect.
-To access cbiect prapeties -
Sunkax [Link]
eg tudent.ns2

-To occessmethads--
[Link];
[Link]
B Moin Eveoti

-In IS an event is away to tat executing


Hhe code
ea mouseclick o butonclick, foamload

-IS reacts to the event Lith the help o


event handling
-The fnckon LuiHen forent handling is called
as evernt handle.
PAGE

DATE

waite a TS asramio implement pacpetles


of cbject.
Khtml>
<head>
<Eitle> Ohiect Prapeaties sltitle>
<lhead>
sbady
<Scaipt language "javascaipt" typesteatjauascaipt">
Jat Student =

mo2
Rname"fayal,
Iname"Shela"
cdassT
[Link] ("5TUDENT INÉORIMATION";
[Link]('<br RolLNo"+[Link]):,
[Link]('kr>kst Name [Link]
[Link] ('kba >last Name ="+Gtudent Inama);
[Link] Cskr>class ="[Link]);
<lscaipt>
klbody>
Klhtml>
utpu obËect Paapen ties
GTUDENT INEORMATTN
Roll o =12
First Name =Paal
Last Name = shela
Class Ty
DATE

Ega w ite a TS progom to impl ernent meihads o


dhjech.

<html
<head
<title> Obiect Methads <litle>
<lhead
<hody>
<scaipt language =iauascoipt" type "textljavascigy
Nas student

AnamePayal
Iname Shela";
classTy
fullname:funcion ()
[Link] ( Gtodent TInlsamoticr):
documertiuoite('kbr> Ral) Na ="t
[Link]
[Link]('<brFinst Name ="
+[Link];
[Link] ('<bm>last Name "
+Gtudeat. Inamel
documentcike ('<b>class ="+student
class,

[Link]
<lscaipt>
PAGE No

DATE

slbady2
khtmlz

Qutputi
Opevatohs in ava Geipt.
[Link] aperator
2 Compaison opercato
2 Logical opesata
4Bituwise opemato
s Assianment apesator
a CondiEiona /Teyn ary operato
DAihmetic apento
Sor No. Opeato Meaninq

Additin
2. k Gubtraction
3. Multipication
Division
5. Modulus

C¡ nike aa poqram to implement aithmekc


Lopenatos.
<html
<head
<iEle> Arithmetic Operators <Ititle>
<lhead>
<body>
<scmipt language ="javascaipt" type "eatljaasoipl
Na a =lob-5:
[Link] ('<br> Addition "+ (a+b));
document.«wike('sor> 5ubiaaciona" (o-b))
[Link](kbt1ul iolicakions"+ (oxb)):
[Link] '<r>Diviaion="+(o/b))
[Link] ('<br> t1 odulus.s (akb)):
<lacaipt>
<lbody>
<thtml>

|Aoithmetic operators
Addition - 15
Bubtraction = 5
Mulliplication=
Division =2
Modulus -0

2\Compariaon aperecto
|No. Opemator
Meaning
< less than
2 less than or equal ta
qreate than
4
greater than o equal to
exactls equal to
not equal to

*==(Hene dottpe e not considey & onu values


equal to)
eve bth yalues & datatype ase Cansidez)
Eqwite o poarom to implernent companisan ape
<html>
<head>
<tile> CampatSon Openraton <Litle>
<Ihead>
Khody>
<scigt languagejauascaipt" typea"tetjaNascagy
[Link] ("<br > a<b=+laxbl;
[Link] ('kbo> a>b="t lazbl)
[Link] ("<b> as=b =" +la<=b)):
dacumentciite("<br a=b="+(a=b)):
[Link]("<by al=b=" +la =b)]:
documentite("<by> a==b +lazb)
[Link](cba>a==b '+la===b);
<lscript
<lbedy>
<lbtml

Output

LCompazon peaate
a<b= Toue
a>b= alse
a<=b =True
a=b= False
a!=b= Taue
a c = Torue
a===c False
PAE

DATE

2Logicalcpenaton

GaNo Openatct Maaning


1 |Logical AND
Loqical OR
Logical NoT

Eg aite a rogam to implement lagical operaler.


<html>
<head>
ile> Logical Gperatoz <ltile>
<lhead>
cbody>
<Scmipt lanquage ="javascaipt'" type testljovascaip

[Link] ("<by >lagical AND=" +a!=b)


&ecacb)):
[Link]("<brs logical oR " +(lazb) |L
(a==b)):
[Link]("<br>Loqical NOT ="+
[Link]'<brlesical NoT ="t! (a>b):
<lscipt>
<lbodu
<lbtm
ATE

Outputi

lagical apaaten.
LogicalAND = Tãue
Lagical GR = False
Loqical NOT =Ealse
TLoaical NoT = Taue

A8ituiee apenatorr
operaton
Meaning
1 & BiAoise AND
Bitwjse OR
Bitaoise XOR
Bitwise NOT
5 < Left shift
G.
Riabt sht
[Link] a pogtam Lo implemnent Bikoise cpecks
<html
<head>
<title Bitaise openatonr Klttle>
Klhead>
Sbady
<Scipt anguage "iavascaipt" Aype-'textl/auasapt
[Link]'<hr> Biuie AND "+ (5&))
document..uite ('<br>itusige R="+(5l2))
[Link](Kbr> eitoise XOR=" +(5^D)
DATE

[Link]("<brs Bitusise NoT ="( ) ;


document..conite('<b> eitusiee Left shitt =
(5<<0)
[Link]("<bn>Bituise Right shift= +
(5>1));
<lscript>
<lbody>
<Ihtml

|eituoise Opeator
eitoiee AND =1
Bituuise oR 5
etwise xoR = 4
Bitoiee NoT =-8
Bituojse lelt shi!t =lo
eitaise Right shift=2

You might also like