<s>
JavaScript	B-Language
(	O
)	O
,	O
often	O
abbreviated	O
as	O
JS	O
,	O
is	O
a	O
programming	O
language	O
that	O
is	O
one	O
of	O
the	O
core	O
technologies	O
of	O
the	O
World	O
Wide	O
Web	O
,	O
alongside	O
HTML	B-Language
and	O
CSS	B-Language
.	O
</s>
<s>
As	O
of	O
2022	O
,	O
98%	O
of	O
websites	O
use	O
JavaScript	B-Language
on	O
the	O
client	B-Protocol
side	O
for	O
webpage	O
behavior	O
,	O
often	O
incorporating	O
third-party	O
libraries	B-Language
.	O
</s>
<s>
All	O
major	O
web	B-Application
browsers	I-Application
have	O
a	O
dedicated	O
JavaScript	B-Language
engine	I-Language
to	O
execute	O
the	O
code	O
on	O
users	O
 '	O
devices	O
.	O
</s>
<s>
JavaScript	B-Language
is	O
a	O
high-level	B-Language
,	O
often	O
just-in-time	O
compiled	B-Language
language	O
that	O
conforms	O
to	O
the	O
ECMAScript	B-Language
standard	O
.	O
</s>
<s>
It	O
has	O
dynamic	O
typing	O
,	O
prototype-based	B-Application
object-orientation	B-Language
,	O
and	O
first-class	B-Application
functions	I-Application
.	O
</s>
<s>
It	O
is	O
multi-paradigm	O
,	O
supporting	O
event-driven	B-Application
,	O
functional	B-Language
,	O
and	O
imperative	B-Application
programming	I-Application
styles	O
.	O
</s>
<s>
It	O
has	O
application	B-Application
programming	I-Application
interfaces	I-Application
(	O
APIs	B-General_Concept
)	O
for	O
working	O
with	O
text	O
,	O
dates	O
,	O
regular	B-Language
expressions	I-Language
,	O
standard	O
data	B-General_Concept
structures	I-General_Concept
,	O
and	O
the	O
Document	B-General_Concept
Object	I-General_Concept
Model	I-General_Concept
(	O
DOM	B-General_Concept
)	O
.	O
</s>
<s>
The	O
ECMAScript	B-Language
standard	O
does	O
not	O
include	O
any	O
input/output	B-General_Concept
(	O
I/O	B-General_Concept
)	O
,	O
such	O
as	O
networking	B-Architecture
,	O
storage	B-Application
,	O
or	O
graphics	O
facilities	O
.	O
</s>
<s>
In	O
practice	O
,	O
the	O
web	B-Application
browser	I-Application
or	O
other	O
runtime	B-Device
system	I-Device
provides	O
JavaScript	B-Language
APIs	B-General_Concept
for	O
I/O	B-General_Concept
.	O
</s>
<s>
JavaScript	B-Language
engines	I-Language
were	O
originally	O
used	O
only	O
in	O
web	B-Application
browsers	I-Application
,	O
but	O
are	O
now	O
core	O
components	O
of	O
some	O
servers	B-Application
and	O
a	O
variety	O
of	O
applications	B-Application
.	O
</s>
<s>
The	O
most	O
popular	O
runtime	B-Device
system	I-Device
for	O
this	O
usage	O
is	O
Node.js	B-Language
.	O
</s>
<s>
Although	O
Java	B-Language
and	O
JavaScript	B-Language
are	O
similar	O
in	O
name	O
,	O
syntax	O
,	O
and	O
respective	O
standard	B-Library
libraries	I-Library
,	O
the	O
two	O
languages	O
are	O
distinct	O
and	O
differ	O
greatly	O
in	O
design	O
.	O
</s>
<s>
The	O
first	O
popular	O
web	B-Application
browser	I-Application
with	O
a	O
graphical	B-Application
user	I-Application
interface	I-Application
,	O
Mosaic	B-Application
,	O
was	O
released	O
in	O
1993	O
.	O
</s>
<s>
Accessible	O
to	O
non-technical	O
people	O
,	O
it	O
played	O
a	O
prominent	O
role	B-General_Concept
in	O
the	O
rapid	O
growth	O
of	O
the	O
nascent	O
World	O
Wide	O
Web	O
.	O
</s>
<s>
The	O
lead	O
developers	O
of	O
Mosaic	B-Application
then	O
founded	O
the	O
Netscape	B-Protocol
corporation	O
,	O
which	O
released	O
a	O
more	O
polished	O
browser	B-Application
,	O
Netscape	B-Protocol
Navigator	I-Protocol
,	O
in	O
1994	O
.	O
</s>
<s>
During	O
these	O
formative	O
years	O
of	O
the	O
Web	O
,	O
web	O
pages	O
could	O
only	O
be	O
static	O
,	O
lacking	O
the	O
capability	O
for	O
dynamic	O
behavior	O
after	O
the	O
page	O
was	O
loaded	O
in	O
the	O
browser	B-Application
.	O
</s>
<s>
There	O
was	O
a	O
desire	O
in	O
the	O
flourishing	O
web	O
development	O
scene	O
to	O
remove	O
this	O
limitation	O
,	O
so	O
in	O
1995	O
,	O
Netscape	B-Protocol
decided	O
to	O
add	O
a	O
scripting	B-Language
language	I-Language
to	O
Navigator	O
.	O
</s>
<s>
They	O
pursued	O
two	O
routes	O
to	O
achieve	O
this	O
:	O
collaborating	O
with	O
Sun	O
Microsystems	O
to	O
embed	O
the	O
Java	B-Language
programming	I-Language
language	I-Language
,	O
while	O
also	O
hiring	O
Brendan	O
Eich	O
to	O
embed	O
the	O
Scheme	B-Language
language	I-Language
.	O
</s>
<s>
Netscape	B-Protocol
management	O
soon	O
decided	O
that	O
the	O
best	O
option	O
was	O
for	O
Eich	O
to	O
devise	O
a	O
new	O
language	O
,	O
with	O
syntax	O
similar	O
to	O
Java	B-Language
and	O
less	O
like	O
Scheme	B-Language
or	O
other	O
extant	O
scripting	B-Language
languages	I-Language
.	O
</s>
<s>
Although	O
the	O
new	O
language	O
and	O
its	O
interpreter	B-Application
implementation	O
were	O
called	O
LiveScript	O
when	O
first	O
shipped	O
as	O
part	O
of	O
a	O
Navigator	O
beta	O
in	O
September	O
1995	O
,	O
the	O
name	O
was	O
changed	O
to	O
JavaScript	B-Language
for	O
the	O
official	O
release	O
in	O
December	O
.	O
</s>
<s>
The	O
choice	O
of	O
the	O
JavaScript	B-Language
name	O
has	O
caused	O
confusion	O
,	O
implying	O
that	O
it	O
is	O
directly	O
related	O
to	O
Java	B-Language
.	O
</s>
<s>
At	O
the	O
time	O
,	O
the	O
dot-com	O
boom	O
had	O
begun	O
and	O
Java	B-Language
was	O
the	O
hot	O
new	O
language	O
,	O
so	O
Eich	O
considered	O
the	O
JavaScript	B-Language
name	O
a	O
marketing	O
ploy	O
by	O
Netscape	B-Protocol
.	O
</s>
<s>
Microsoft	O
debuted	O
Internet	B-Application
Explorer	I-Application
in	O
1995	O
,	O
leading	O
to	O
a	O
browser	B-Application
war	I-Application
with	O
Netscape	B-Protocol
.	O
</s>
<s>
On	O
the	O
JavaScript	B-Language
front	O
,	O
Microsoft	O
reverse-engineered	O
the	O
Navigator	O
interpreter	B-Application
to	O
create	O
its	O
own	O
,	O
called	O
JScript	B-Language
.	O
</s>
<s>
JScript	B-Language
was	O
first	O
released	O
in	O
1996	O
,	O
alongside	O
initial	O
support	O
for	O
CSS	B-Language
and	O
extensions	O
to	O
HTML	B-Language
.	O
</s>
<s>
These	O
differences	O
made	O
it	O
difficult	O
for	O
developers	O
to	O
make	O
their	O
websites	O
work	O
well	O
in	O
both	O
browsers	B-Application
,	O
leading	O
to	O
widespread	O
use	O
of	O
"	O
best	O
viewed	O
in	O
Netscape	B-Protocol
"	O
and	O
"	O
best	O
viewed	O
in	O
Internet	B-Application
Explorer	I-Application
"	O
logos	O
for	O
several	O
years	O
.	O
</s>
<s>
In	O
November	O
1996	O
,	O
Netscape	B-Protocol
submitted	O
JavaScript	B-Language
to	O
Ecma	O
International	O
,	O
as	O
the	O
starting	O
point	O
for	O
a	O
standard	O
specification	O
that	O
all	O
browser	B-Application
vendors	O
could	O
conform	O
to	O
.	O
</s>
<s>
This	O
led	O
to	O
the	O
official	O
release	O
of	O
the	O
first	O
ECMAScript	B-Language
language	O
specification	O
in	O
June	O
1997	O
.	O
</s>
<s>
The	O
standards	O
process	O
continued	O
for	O
a	O
few	O
years	O
,	O
with	O
the	O
release	O
of	O
ECMAScript	B-Language
2	O
in	O
June	O
1998	O
and	O
ECMAScript	B-Language
3	O
in	O
December	O
1999	O
.	O
</s>
<s>
Work	O
on	O
ECMAScript	B-Language
4	O
began	O
in	O
2000	O
.	O
</s>
<s>
Meanwhile	O
,	O
Microsoft	O
gained	O
an	O
increasingly	O
dominant	O
position	O
in	O
the	O
browser	B-Application
market	O
.	O
</s>
<s>
By	O
the	O
early	O
2000s	O
,	O
Internet	B-Application
Explorer	I-Application
's	O
market	O
share	O
reached	O
95%	O
.	O
</s>
<s>
This	O
meant	O
that	O
JScript	B-Language
became	O
the	O
de	O
facto	O
standard	O
for	O
client-side	B-Operating_System
scripting	O
on	O
the	O
Web	O
.	O
</s>
<s>
Microsoft	O
initially	O
participated	O
in	O
the	O
standards	O
process	O
and	O
implemented	O
some	O
proposals	O
in	O
its	O
JScript	B-Language
language	O
,	O
but	O
eventually	O
it	O
stopped	O
collaborating	O
on	O
Ecma	O
work	O
.	O
</s>
<s>
Thus	O
ECMAScript	B-Language
4	O
was	O
mothballed	O
.	O
</s>
<s>
During	O
the	O
period	O
of	O
Internet	B-Application
Explorer	I-Application
dominance	O
in	O
the	O
early	O
2000s	O
,	O
client-side	B-Operating_System
scripting	O
was	O
stagnant	O
.	O
</s>
<s>
This	O
started	O
to	O
change	O
in	O
2004	O
,	O
when	O
the	O
successor	O
of	O
Netscape	B-Protocol
,	O
Mozilla	B-Operating_System
,	O
released	O
the	O
Firefox	B-Application
browser	I-Application
.	O
</s>
<s>
Firefox	B-Application
was	O
well	O
received	O
by	O
many	O
,	O
taking	O
significant	O
market	O
share	O
from	O
Internet	B-Application
Explorer	I-Application
.	O
</s>
<s>
In	O
2005	O
,	O
Mozilla	B-Operating_System
joined	O
ECMA	O
International	O
,	O
and	O
work	O
started	O
on	O
the	O
ECMAScript	B-Language
for	I-Language
XML	I-Language
(	O
E4X	B-Language
)	O
standard	O
.	O
</s>
<s>
This	O
led	O
to	O
Mozilla	B-Operating_System
working	O
jointly	O
with	O
Macromedia	O
(	O
later	O
acquired	O
by	O
Adobe	O
Systems	O
)	O
,	O
who	O
were	O
implementing	O
E4X	B-Language
in	O
their	O
ActionScript	B-Operating_System
3	O
language	O
,	O
which	O
was	O
based	O
on	O
an	O
ECMAScript	B-Language
4	O
draft	O
.	O
</s>
<s>
The	O
goal	O
became	O
standardizing	O
ActionScript	B-Operating_System
3	O
as	O
the	O
new	O
ECMAScript	B-Language
4	O
.	O
</s>
<s>
To	O
this	O
end	O
,	O
Adobe	O
Systems	O
released	O
the	O
Tamarin	B-Language
implementation	O
as	O
an	O
open	B-Application
source	I-Application
project	O
.	O
</s>
<s>
However	O
,	O
Tamarin	B-Language
and	O
ActionScript	B-Operating_System
3	O
were	O
too	O
different	O
from	O
established	O
client-side	B-Operating_System
scripting	O
,	O
and	O
without	O
cooperation	O
from	O
Microsoft	O
,	O
ECMAScript	B-Language
4	O
never	O
reached	O
fruition	O
.	O
</s>
<s>
Meanwhile	O
,	O
very	O
important	O
developments	O
were	O
occurring	O
in	O
open-source	B-Application
communities	O
not	O
affiliated	O
with	O
ECMA	O
work	O
.	O
</s>
<s>
In	O
2005	O
,	O
Jesse	O
James	O
Garrett	O
released	O
a	O
white	O
paper	O
in	O
which	O
he	O
coined	O
the	O
term	O
Ajax	B-General_Concept
and	O
described	O
a	O
set	O
of	O
technologies	O
,	O
of	O
which	O
JavaScript	B-Language
was	O
the	O
backbone	O
,	O
to	O
create	O
web	B-Application
applications	I-Application
where	O
data	O
can	O
be	O
loaded	O
in	O
the	O
background	O
,	O
avoiding	O
the	O
need	O
for	O
full	O
page	O
reloads	O
.	O
</s>
<s>
This	O
sparked	O
a	O
renaissance	O
period	O
of	O
JavaScript	B-Language
,	O
spearheaded	O
by	O
open-source	B-Application
libraries	B-Language
and	O
the	O
communities	O
that	O
formed	O
around	O
them	O
.	O
</s>
<s>
Many	O
new	O
libraries	B-Language
were	O
created	O
,	O
including	O
jQuery	B-Language
,	O
Prototype	B-Language
,	O
Dojo	B-General_Concept
Toolkit	I-General_Concept
,	O
and	O
MooTools	B-Language
.	O
</s>
<s>
Google	B-Application
debuted	O
its	O
Chrome	B-Application
browser	I-Application
in	O
2008	O
,	O
with	O
the	O
V8	B-Language
JavaScript	I-Language
engine	I-Language
that	O
was	O
faster	O
than	O
its	O
competition	O
.	O
</s>
<s>
The	O
key	O
innovation	O
was	O
just-in-time	O
compilation	B-Language
(	O
JIT	O
)	O
,	O
so	O
other	O
browser	B-Application
vendors	O
needed	O
to	O
overhaul	O
their	O
engines	O
for	O
JIT	O
.	O
</s>
<s>
The	O
result	O
was	O
the	O
ECMAScript	B-Language
5	O
standard	O
,	O
released	O
in	O
December	O
2009	O
.	O
</s>
<s>
Ambitious	O
work	O
on	O
the	O
language	O
continued	O
for	O
several	O
years	O
,	O
culminating	O
in	O
an	O
extensive	O
collection	O
of	O
additions	O
and	O
refinements	O
being	O
formalized	O
with	O
the	O
publication	O
of	O
ECMAScript	B-Language
6	O
in	O
2015	O
.	O
</s>
<s>
The	O
creation	O
of	O
Node.js	B-Language
in	O
2009	O
by	O
Ryan	O
Dahl	O
sparked	O
a	O
significant	O
increase	O
in	O
the	O
usage	O
of	O
JavaScript	B-Language
outside	O
of	O
web	B-Application
browsers	I-Application
.	O
</s>
<s>
Node	O
combines	O
the	O
V8	B-Language
engine	O
,	O
an	O
event	B-General_Concept
loop	I-General_Concept
,	O
and	O
I/O	B-General_Concept
APIs	B-General_Concept
,	O
thereby	O
providing	O
a	O
stand-alone	O
JavaScript	B-Language
runtime	B-Device
system	I-Device
.	O
</s>
<s>
As	O
of	O
2018	O
,	O
Node	O
had	O
been	O
used	O
by	O
millions	O
of	O
developers	O
,	O
and	O
npm	B-Language
had	O
the	O
most	O
modules	O
of	O
any	O
package	B-Application
manager	I-Application
in	O
the	O
world	O
.	O
</s>
<s>
The	O
ECMAScript	B-Language
draft	O
specification	O
is	O
currently	O
maintained	O
openly	O
on	O
GitHub	B-Application
,	O
and	O
editions	O
are	O
produced	O
via	O
regular	O
annual	O
snapshots	O
.	O
</s>
<s>
The	O
current	O
JavaScript	B-Language
ecosystem	O
has	O
many	O
libraries	B-Language
and	O
frameworks	B-Application
,	O
established	O
programming	O
practices	O
,	O
and	O
substantial	O
usage	O
of	O
JavaScript	B-Language
outside	O
of	O
web	B-Application
browsers	I-Application
.	O
</s>
<s>
Plus	O
,	O
with	O
the	O
rise	O
of	O
single-page	B-Application
applications	I-Application
and	O
other	O
JavaScript-heavy	O
websites	O
,	O
several	O
transpilers	B-Language
have	O
been	O
created	O
to	O
aid	O
the	O
development	O
process	O
.	O
</s>
<s>
"	O
JavaScript	B-Language
"	O
is	O
a	O
trademark	O
of	O
Oracle	B-Application
Corporation	I-Application
in	O
the	O
United	O
States	O
.	O
</s>
<s>
The	O
trademark	O
was	O
originally	O
issued	O
to	O
Sun	O
Microsystems	O
on	O
6	O
May	O
1997	O
,	O
and	O
was	O
transferred	O
to	O
Oracle	B-Application
when	O
they	O
acquired	O
Sun	O
in	O
2009	O
.	O
</s>
<s>
JavaScript	B-Language
is	O
the	O
dominant	O
client-side	B-Operating_System
scripting	B-Language
language	I-Language
of	O
the	O
Web	O
,	O
with	O
98%	O
of	O
all	O
websites	O
using	O
it	O
for	O
this	O
purpose	O
.	O
</s>
<s>
Scripts	O
are	O
embedded	O
in	O
or	O
included	O
from	O
HTML	B-Language
documents	O
and	O
interact	O
with	O
the	B-General_Concept
DOM	I-General_Concept
.	O
</s>
<s>
All	O
major	O
web	B-Application
browsers	I-Application
have	O
a	O
built-in	O
JavaScript	B-Language
engine	I-Language
that	O
executes	O
the	O
code	O
on	O
the	O
user	O
's	O
device	O
.	O
</s>
<s>
Loading	O
new	O
web	O
page	O
content	O
without	O
reloading	O
the	O
page	O
,	O
via	O
Ajax	B-General_Concept
or	O
a	O
WebSocket	B-Protocol
.	O
</s>
<s>
Playing	O
browser	B-Protocol
games	I-Protocol
.	O
</s>
<s>
Validating	O
input	O
values	O
of	O
a	O
web	B-General_Concept
form	I-General_Concept
before	O
the	O
data	O
is	O
sent	O
to	O
a	O
web	B-Application
server	I-Application
.	O
</s>
<s>
Storing	O
and	O
retrieving	O
data	O
on	O
the	O
user	O
's	O
device	O
,	O
via	O
the	O
storage	B-Application
or	O
IndexedDB	O
standards	O
.	O
</s>
<s>
Over	O
80%	O
of	O
websites	O
use	O
a	O
third-party	O
JavaScript	B-Language
library	B-Library
or	O
web	B-Application
framework	I-Application
for	O
their	O
client-side	B-Operating_System
scripting	O
.	O
</s>
<s>
jQuery	B-Language
is	O
by	O
far	O
the	O
most	O
popular	O
client-side	B-Operating_System
library	B-Library
,	O
used	O
by	O
over	O
75%	O
of	O
websites	O
.	O
</s>
<s>
Facebook	B-Application
created	O
the	O
React	B-Application
library	B-Library
for	O
its	O
website	O
and	O
later	O
released	O
it	O
as	O
open	B-Application
source	I-Application
;	O
other	O
sites	O
,	O
including	O
Twitter	B-Application
,	O
now	O
use	O
it	O
.	O
</s>
<s>
Likewise	O
,	O
the	O
Angular	B-Language
framework	O
created	O
by	O
Google	B-Application
for	O
its	O
websites	O
,	O
including	O
YouTube	B-General_Concept
and	O
Gmail	B-Application
,	O
is	O
now	O
an	O
open	B-Application
source	I-Application
project	O
used	O
by	O
others	O
.	O
</s>
<s>
In	O
contrast	O
,	O
the	O
term	O
"	O
Vanilla	O
JS	O
"	O
has	O
been	O
coined	O
for	O
websites	O
not	O
using	O
any	O
libraries	B-Language
or	O
frameworks	B-Application
,	O
instead	O
relying	O
entirely	O
on	O
standard	O
JavaScript	B-Language
functionality	O
.	O
</s>
<s>
The	O
use	O
of	O
JavaScript	B-Language
has	O
expanded	O
beyond	O
its	O
web	B-Application
browser	I-Application
roots	O
.	O
</s>
<s>
JavaScript	B-Language
engines	I-Language
are	O
now	O
embedded	O
in	O
a	O
variety	O
of	O
other	O
software	O
systems	O
,	O
both	O
for	O
server-side	B-Application
website	O
deployments	O
and	O
non-browser	O
applications	O
.	O
</s>
<s>
Initial	O
attempts	O
at	O
promoting	O
server-side	B-Application
JavaScript	B-Language
usage	O
were	O
Netscape	B-Protocol
Enterprise	B-Application
Server	I-Application
and	O
Microsoft	O
's	O
Internet	B-Application
Information	I-Application
Services	I-Application
,	O
but	O
they	O
were	O
small	O
niches	O
.	O
</s>
<s>
Server-side	B-Application
usage	O
eventually	O
started	O
to	O
grow	O
in	O
the	O
late	O
2000s	O
,	O
with	O
the	O
creation	O
of	O
Node.js	B-Language
and	O
other	B-Language
approaches	I-Language
.	O
</s>
<s>
Electron	B-Operating_System
,	O
Cordova	B-Protocol
,	O
React	B-Application
Native	I-Application
,	O
and	O
other	O
application	B-Application
frameworks	I-Application
have	O
been	O
used	O
to	O
create	O
many	O
applications	B-Application
with	O
behavior	O
implemented	O
in	O
JavaScript	B-Language
.	O
</s>
<s>
Other	O
non-browser	O
applications	O
include	O
Adobe	B-Application
Acrobat	I-Application
support	O
for	O
scripting	O
PDF	B-Application
documents	I-Application
and	O
GNOME	B-Language
Shell	I-Language
extensions	O
written	O
in	O
JavaScript	B-Language
.	O
</s>
<s>
JavaScript	B-Language
has	O
recently	O
begun	O
to	O
appear	O
in	O
some	O
embedded	B-Architecture
systems	I-Architecture
,	O
usually	O
by	O
leveraging	O
Node.js	B-Language
.	O
</s>
<s>
The	O
following	O
features	O
are	O
common	O
to	O
all	O
conforming	O
ECMAScript	B-Language
implementations	O
unless	O
explicitly	O
specified	O
otherwise	O
.	O
</s>
<s>
JavaScript	B-Language
supports	O
much	O
of	O
the	O
structured	B-Language
programming	I-Language
syntax	O
from	O
C	B-Language
(	O
e.g.	O
,	O
if	O
statements	O
,	O
while	O
loops	O
,	O
switch	O
statements	O
,	O
do	O
while	O
loops	O
,	O
etc	O
.	O
)	O
.	O
</s>
<s>
One	O
partial	O
exception	O
is	O
scoping	B-Language
:	O
originally	O
JavaScript	B-Language
only	O
had	O
function	O
scoping	B-Language
with	O
var	O
;	O
block	O
scoping	B-Language
was	O
added	O
in	O
ECMAScript	B-Language
2015	O
with	O
the	B-Application
keywords	I-Application
let	O
and	O
const	O
.	O
</s>
<s>
Like	O
C	B-Language
,	O
JavaScript	B-Language
makes	O
a	O
distinction	O
between	O
expressions	O
and	O
statements	O
.	O
</s>
<s>
One	O
syntactic	O
difference	O
from	O
C	B-Language
is	O
automatic	O
semicolon	O
insertion	O
,	O
which	O
allow	O
semicolons	O
(	O
which	O
terminate	O
statements	O
)	O
to	O
be	O
omitted	O
.	O
</s>
<s>
JavaScript	B-Language
is	O
weakly	O
typed	O
,	O
which	O
means	O
certain	O
types	O
are	O
implicitly	O
cast	O
depending	O
on	O
the	O
operation	O
used	O
.	O
</s>
<s>
These	O
processes	O
can	O
be	O
modified	O
by	O
defining	O
toString	B-Language
and	O
valueOf	O
functions	O
on	O
the	O
prototype	B-Language
for	O
string	O
and	O
number	O
casting	O
respectively	O
.	O
</s>
<s>
JavaScript	B-Language
has	O
received	O
criticism	O
for	O
the	O
way	O
it	O
implements	O
these	O
conversions	O
as	O
the	O
complexity	O
of	O
the	O
rules	O
can	O
be	O
mistaken	O
for	O
inconsistency	O
.	O
</s>
<s>
TypingJavaScript	O
is	O
dynamically	O
typed	O
like	O
most	O
other	O
scripting	B-Language
languages	I-Language
.	O
</s>
<s>
JavaScript	B-Language
supports	O
various	O
ways	O
to	O
test	O
the	O
type	O
of	O
objects	O
,	O
including	O
duck	B-Application
typing	I-Application
.	O
</s>
<s>
Run-time	O
evaluation	O
JavaScript	B-Language
includes	O
an	O
eval	O
function	O
that	O
can	O
execute	O
statements	O
provided	O
as	O
strings	O
at	O
run-time	O
.	O
</s>
<s>
Prototypal	B-Application
inheritance	I-Application
in	O
JavaScript	B-Language
is	O
described	O
by	O
Douglas	O
Crockford	O
as	O
:	O
</s>
<s>
In	O
JavaScript	B-Language
,	O
an	O
object	O
is	O
an	O
associative	B-Application
array	I-Application
,	O
augmented	O
with	O
a	O
prototype	B-Language
(	O
see	O
below	O
)	O
;	O
each	O
key	O
provides	O
the	O
name	O
for	O
an	O
object	O
property	B-Language
,	O
and	O
there	O
are	O
two	O
syntactical	O
ways	O
to	O
specify	O
such	O
a	O
name	O
:	O
dot	B-Language
notation	I-Language
(	O
obj.x	O
=	O
10	O
)	O
and	O
bracket	O
notation	O
(	O
obj['x']	O
=	O
10	O
)	O
.	O
</s>
<s>
A	O
property	B-Language
may	O
be	O
added	O
,	O
rebound	O
,	O
or	O
deleted	O
at	O
run-time	O
.	O
</s>
<s>
Most	O
properties	B-Language
of	O
an	O
object	O
(	O
and	O
any	O
property	B-Language
that	O
belongs	O
to	O
an	O
object	O
's	O
prototype	B-Language
inheritance	B-Language
chain	O
)	O
can	O
be	O
enumerated	O
using	O
a	O
for	O
...	O
in	O
loop	O
.	O
</s>
<s>
Prototypes	B-Application
JavaScript	B-Language
uses	O
prototypes	B-Application
where	O
many	O
other	O
object-oriented	B-Language
languages	I-Language
use	O
classes	O
for	O
inheritance	B-Language
.	O
</s>
<s>
It	O
is	O
possible	O
to	O
simulate	O
many	O
class-based	B-Application
features	O
with	O
prototypes	B-Application
in	O
JavaScript	B-Language
.	O
</s>
<s>
Functions	O
as	O
object	O
constructors	O
Functions	O
double	O
as	O
object	O
constructors	O
,	O
along	O
with	O
their	O
typical	O
role	B-General_Concept
.	O
</s>
<s>
Prefixing	O
a	O
function	O
call	O
with	O
new	O
will	O
create	O
an	O
instance	O
of	O
a	O
prototype	B-Language
,	O
inheriting	O
properties	B-Language
and	O
methods	O
from	O
the	O
constructor	O
(	O
including	O
properties	B-Language
from	O
the	O
Object	O
prototype	B-Language
)	O
.	O
</s>
<s>
ECMAScript	B-Language
5	O
offers	O
the	O
Object.create	O
method	B-Language
,	O
allowing	O
explicit	O
creation	O
of	O
an	O
instance	O
without	O
automatically	O
inheriting	O
from	O
the	O
Object	O
prototype	B-Language
(	O
older	O
environments	O
can	O
assign	O
the	O
prototype	B-Language
to	O
null	O
)	O
.	O
</s>
<s>
The	O
constructor	O
's	O
prototype	B-Language
property	B-Language
determines	O
the	O
object	O
used	O
for	O
the	O
new	O
object	O
's	O
internal	O
prototype	B-Language
.	O
</s>
<s>
New	O
methods	O
can	O
be	O
added	O
by	O
modifying	O
the	O
prototype	B-Language
of	O
the	O
function	O
used	O
as	O
a	O
constructor	O
.	O
</s>
<s>
JavaScript	B-Language
's	O
built-in	O
constructors	O
,	O
such	O
as	O
Array	O
or	O
Object	O
,	O
also	O
have	O
prototypes	B-Application
that	O
can	O
be	O
modified	O
.	O
</s>
<s>
While	O
it	O
is	O
possible	O
to	O
modify	O
the	O
Object	O
prototype	B-Language
,	O
it	O
is	O
generally	O
considered	O
bad	O
practice	O
because	O
most	O
objects	O
in	O
JavaScript	B-Language
will	O
inherit	O
methods	O
and	O
properties	B-Language
from	O
the	O
Object	O
prototype	B-Language
,	O
and	O
they	O
may	O
not	O
expect	O
the	O
prototype	B-Language
to	O
be	O
modified	O
.	O
</s>
<s>
Functions	O
as	O
methods	O
Unlike	O
many	O
object-oriented	B-Language
languages	I-Language
,	O
there	O
is	O
no	O
distinction	O
between	O
a	O
function	O
definition	O
and	O
a	O
method	B-Language
definition	O
.	O
</s>
<s>
Rather	O
,	O
the	O
distinction	O
occurs	O
during	O
function	O
calling	O
:	O
when	O
a	O
function	O
is	O
called	O
as	O
a	O
method	B-Language
of	O
an	O
object	O
,	O
the	O
function	O
's	O
local	O
this	O
keyword	O
is	O
bound	O
to	O
that	O
object	O
for	O
that	O
invocation	O
.	O
</s>
<s>
JavaScript	B-Language
functions	O
are	O
first-class	B-Application
;	O
a	O
function	O
is	O
considered	O
to	O
be	O
an	O
object	O
.	O
</s>
<s>
As	O
such	O
,	O
a	O
function	O
may	O
have	O
properties	B-Language
and	O
methods	O
,	O
such	O
as	O
.call( )	O
and	O
.bind( )	O
.	O
</s>
<s>
In	O
addition	O
,	O
each	O
nested	O
function	O
forms	O
a	O
lexical	B-Language
closure	I-Language
:	O
the	O
lexical	O
scope	O
of	O
the	O
outer	O
function	O
(	O
including	O
any	O
constant	O
,	O
local	O
variable	O
,	O
or	O
argument	O
value	O
)	O
becomes	O
part	O
of	O
the	O
internal	O
state	O
of	O
each	O
inner	O
function	O
object	O
,	O
even	O
after	O
execution	O
of	O
the	O
outer	O
function	O
concludes	O
.	O
</s>
<s>
JavaScript	B-Language
also	O
supports	O
anonymous	B-General_Concept
functions	I-General_Concept
.	O
</s>
<s>
JavaScript	B-Language
supports	O
implicit	O
and	O
explicit	O
delegation	B-Application
.	O
</s>
<s>
Functions	O
as	O
roles	O
(	O
Traits	O
and	O
Mixins	B-Language
)	O
JavaScript	B-Language
natively	O
supports	O
various	O
function-based	O
implementations	O
of	O
Role	B-General_Concept
patterns	O
like	O
Traits	O
and	O
Mixins	B-Language
.	O
</s>
<s>
Such	O
a	O
function	O
defines	O
additional	O
behavior	O
by	O
at	O
least	O
one	O
method	B-Language
bound	O
to	O
the	O
this	O
keyword	O
within	O
its	O
function	O
body	O
.	O
</s>
<s>
A	O
Role	B-General_Concept
then	O
has	O
to	O
be	O
delegated	O
explicitly	O
via	O
call	O
or	O
apply	O
to	O
objects	O
that	O
need	O
to	O
feature	O
additional	O
behavior	O
that	O
is	O
not	O
shared	O
via	O
the	O
prototype	B-Language
chain	O
.	O
</s>
<s>
Object	B-Language
composition	I-Language
and	O
inheritance	B-Language
Whereas	O
explicit	O
function-based	O
delegation	B-Application
does	O
cover	O
composition	B-Language
in	O
JavaScript	B-Language
,	O
implicit	O
delegation	B-Application
already	O
happens	O
every	O
time	O
the	O
prototype	B-Language
chain	O
is	O
walked	O
in	O
order	O
to	O
,	O
e.g.	O
,	O
find	O
a	O
method	B-Language
that	O
might	O
be	O
related	O
to	O
but	O
is	O
not	O
directly	O
owned	O
by	O
an	O
object	O
.	O
</s>
<s>
Once	O
the	O
method	B-Language
is	O
found	O
it	O
gets	O
called	O
within	O
this	O
object	O
's	O
context	O
.	O
</s>
<s>
Thus	O
inheritance	B-Language
in	O
JavaScript	B-Language
is	O
covered	O
by	O
a	O
delegation	B-Application
automatism	O
that	O
is	O
bound	O
to	O
the	O
prototype	B-Language
property	B-Language
of	O
constructor	O
functions	O
.	O
</s>
<s>
JavaScript	B-Language
is	O
a	O
zero-index	O
language	O
.	O
</s>
<s>
Run-time	O
environmentJavaScript	O
typically	O
relies	O
on	O
a	O
run-time	B-Device
environment	I-Device
(	O
e.g.	O
,	O
a	O
web	B-Application
browser	I-Application
)	O
to	O
provide	O
objects	O
and	O
methods	O
by	O
which	O
scripts	O
can	O
interact	O
with	O
the	O
environment	O
(	O
e.g.	O
,	O
a	O
web	O
page	O
DOM	B-General_Concept
)	O
.	O
</s>
<s>
These	O
environments	O
are	O
single-threaded	B-Operating_System
.	O
</s>
<s>
JavaScript	B-Language
also	O
relies	O
on	O
the	O
run-time	B-Device
environment	I-Device
to	O
provide	O
the	O
ability	O
to	O
include/import	O
scripts	O
(	O
e.g.	O
,	O
HTML	B-Language
<script>	O
elements	O
)	O
.	O
</s>
<s>
This	O
is	O
not	O
a	O
language	O
feature	O
per	O
se	O
,	O
but	O
it	O
is	O
common	O
in	O
most	O
JavaScript	B-Language
implementations	O
.	O
</s>
<s>
JavaScript	B-Language
processes	O
messages	O
from	O
a	O
queue	B-Application
one	O
at	O
a	O
time	O
.	O
</s>
<s>
JavaScript	B-Language
calls	O
a	O
function	O
associated	O
with	O
each	O
new	O
message	O
,	O
creating	O
a	O
call	B-General_Concept
stack	I-General_Concept
frame	O
with	O
the	O
function	O
's	O
arguments	O
and	O
local	O
variables	O
.	O
</s>
<s>
The	O
call	B-General_Concept
stack	I-General_Concept
shrinks	O
and	O
grows	O
based	O
on	O
the	O
function	O
's	O
needs	O
.	O
</s>
<s>
When	O
the	O
call	B-General_Concept
stack	I-General_Concept
is	O
empty	O
upon	O
function	O
completion	O
,	O
JavaScript	B-Language
proceeds	O
to	O
the	O
next	O
message	O
in	O
the	O
queue	B-Application
.	O
</s>
<s>
This	O
is	O
called	O
the	O
event	B-General_Concept
loop	I-General_Concept
,	O
described	O
as	O
"	O
run	O
to	O
completion	O
"	O
because	O
each	O
message	O
is	O
fully	O
processed	O
before	O
the	O
next	O
message	O
is	O
considered	O
.	O
</s>
<s>
However	O
,	O
the	O
language	O
's	O
concurrency	B-Operating_System
model	I-Operating_System
describes	O
the	O
event	B-General_Concept
loop	I-General_Concept
as	O
non-blocking	B-Architecture
:	O
program	O
input/output	B-General_Concept
is	O
performed	O
using	O
events	O
and	O
callback	O
functions	O
.	O
</s>
<s>
This	O
means	O
,	O
for	O
instance	O
,	O
that	O
JavaScript	B-Language
can	O
process	O
a	O
mouse	O
click	O
while	O
waiting	O
for	O
a	O
database	O
query	O
to	O
return	O
information	O
.	O
</s>
<s>
Variadic	B-Language
functions	I-Language
An	O
indefinite	O
number	O
of	O
parameters	O
can	O
be	O
passed	O
to	O
a	O
function	O
.	O
</s>
<s>
Variadic	B-Language
functions	I-Language
can	O
also	O
be	O
created	O
by	O
using	O
the	O
bind	O
method	B-Language
.	O
</s>
<s>
Array	O
and	O
object	O
literals	O
Like	O
many	O
scripting	B-Language
languages	I-Language
,	O
arrays	O
and	O
objects	O
(	O
associative	B-Application
arrays	I-Application
in	O
other	O
languages	O
)	O
can	O
each	O
be	O
created	O
with	O
a	O
succinct	O
shortcut	O
syntax	O
.	O
</s>
<s>
In	O
fact	O
,	O
these	O
literals	O
form	O
the	O
basis	O
of	O
the	O
JSON	B-General_Concept
data	O
format	O
.	O
</s>
<s>
Regular	B-Language
expressions	I-Language
JavaScript	B-Language
also	O
supports	O
regular	B-Language
expressions	I-Language
in	O
a	O
manner	O
similar	O
to	O
Perl	B-Language
,	O
which	O
provide	O
a	O
concise	O
and	O
powerful	O
syntax	O
for	O
text	O
manipulation	O
that	O
is	O
more	O
sophisticated	O
than	O
the	O
built-in	O
string	O
functions	O
.	O
</s>
<s>
Promises	B-Operating_System
and	O
Async/await	O
JavaScript	B-Language
supports	O
promises	B-Operating_System
and	O
Async/await	O
for	O
handling	O
asynchronous	O
operations	O
.	O
</s>
<s>
A	O
built-in	O
Promise	O
object	O
provides	O
functionality	O
for	O
handling	O
promises	B-Operating_System
and	O
associating	O
handlers	O
with	O
an	O
asynchronous	O
action	O
's	O
eventual	O
result	O
.	O
</s>
<s>
Recently	O
,	O
combinator	O
methods	O
were	O
introduced	O
in	O
the	O
JavaScript	B-Language
specification	O
,	O
which	O
allows	O
developers	O
to	O
combine	O
multiple	O
JavaScript	B-Language
promises	B-Operating_System
and	O
do	O
operations	O
based	O
on	O
different	O
scenarios	O
.	O
</s>
<s>
Async/await	O
allows	O
an	O
asynchronous	O
,	O
non-blocking	B-Architecture
function	O
to	O
be	O
structured	O
in	O
a	O
way	O
similar	O
to	O
an	O
ordinary	O
synchronous	O
function	O
.	O
</s>
<s>
Asynchronous	O
,	O
non-blocking	B-Architecture
code	O
can	O
be	O
written	O
,	O
with	O
minimal	O
overhead	O
,	O
structured	O
similar	O
to	O
traditional	O
synchronous	O
,	O
blocking	O
code	O
.	O
</s>
<s>
Historically	O
,	O
some	O
JavaScript	B-Language
engines	I-Language
supported	O
these	O
non-standard	O
features	O
:	O
</s>
<s>
Variables	O
in	O
JavaScript	B-Language
can	O
be	O
defined	O
using	O
either	O
the	O
var	O
,	O
let	O
or	O
const	O
keywords	O
.	O
</s>
<s>
There	O
is	O
no	O
built-in	O
Input/output	B-General_Concept
functionality	O
in	O
JavaScript	B-Language
,	O
instead	O
it	O
is	O
provided	O
by	O
the	O
run-time	B-Device
environment	I-Device
.	O
</s>
<s>
The	O
ECMAScript	B-Language
specification	O
in	O
edition	O
5.1	O
mentions	O
that	O
"	O
there	O
are	O
no	O
provisions	O
in	O
this	O
specification	O
for	O
input	O
of	O
external	O
data	O
or	O
output	O
of	O
computed	O
results	O
"	O
.	O
</s>
<s>
However	O
,	O
most	O
runtime	B-Device
environments	I-Device
have	O
a	O
console	O
object	O
that	O
can	O
be	O
used	O
to	O
print	O
output	O
.	O
</s>
<s>
Here	O
is	O
a	O
minimalist	O
Hello	O
World	O
program	O
in	O
JavaScript	B-Language
in	O
a	O
runtime	B-Device
environment	I-Device
with	O
a	O
console	O
object	O
:	O
</s>
<s>
In	O
HTML	B-Language
documents	O
,	O
a	O
program	O
like	O
this	O
is	O
required	O
for	O
an	O
output	O
:	O
</s>
<s>
An	O
anonymous	B-General_Concept
function	I-General_Concept
(	O
or	O
lambda	B-General_Concept
)	O
:	O
</s>
<s>
This	O
example	O
shows	O
that	O
,	O
in	O
JavaScript	B-Language
,	O
function	B-Language
closures	I-Language
capture	O
their	O
non-local	O
variables	O
by	O
reference	O
.	O
</s>
<s>
Arrow	B-General_Concept
functions	I-General_Concept
were	O
first	O
introduced	O
in	O
6th	O
Edition	O
-	O
ECMAScript	B-Language
2015	O
.	O
</s>
<s>
They	O
shorten	O
the	O
syntax	O
for	O
writing	O
functions	O
in	O
JavaScript	B-Language
.	O
</s>
<s>
Arrow	B-General_Concept
functions	I-General_Concept
are	O
anonymous	O
,	O
so	O
a	O
variable	O
is	O
needed	O
to	O
refer	O
to	O
them	O
in	O
order	O
to	O
invoke	O
them	O
after	O
their	O
creation	O
,	O
unless	O
surrounded	O
by	O
parenthesis	O
and	O
executed	O
immediately	O
.	O
</s>
<s>
Example	O
of	O
arrow	B-General_Concept
function	I-General_Concept
:	O
</s>
<s>
In	O
JavaScript	B-Language
,	O
objects	O
can	O
be	O
created	O
as	O
instances	O
of	O
a	O
class	O
.	O
</s>
<s>
In	O
JavaScript	B-Language
,	O
objects	O
can	O
be	O
instantiated	O
directly	O
from	O
a	O
function	O
.	O
</s>
<s>
Object	O
functional	B-Language
example	O
:	O
</s>
<s>
Variadic	B-Language
function	I-Language
demonstration	O
(	O
arguments	O
is	O
a	O
special	O
variable	O
)	O
:	O
</s>
<s>
Immediately-invoked	B-Language
function	I-Language
expressions	I-Language
are	O
often	O
used	O
to	O
create	O
closures	B-Language
.	O
</s>
<s>
Closures	B-Language
allow	O
gathering	O
properties	B-Language
and	O
methods	O
in	O
a	O
namespace	O
and	O
making	O
some	O
of	O
them	O
private	O
:	O
</s>
<s>
JavaScript	B-Language
can	O
export	O
and	O
import	O
from	O
modules	O
:	O
</s>
<s>
This	O
sample	O
code	O
displays	O
various	O
JavaScript	B-Language
features	O
.	O
</s>
<s>
The	O
following	O
output	O
should	O
be	O
displayed	O
in	O
the	O
browser	B-Application
window	O
.	O
</s>
<s>
JavaScript	B-Language
and	O
the	B-General_Concept
DOM	I-General_Concept
provide	O
the	O
potential	O
for	O
malicious	O
authors	O
to	O
deliver	O
scripts	O
to	O
run	O
on	O
a	O
client	B-Protocol
computer	I-Protocol
via	O
the	O
Web	O
.	O
</s>
<s>
Browser	B-Application
authors	O
minimize	O
this	O
risk	O
using	O
two	O
restrictions	O
.	O
</s>
<s>
Second	O
,	O
scripts	O
are	O
constrained	O
by	O
the	O
same-origin	B-Protocol
policy	I-Protocol
:	O
scripts	O
from	O
one	O
Website	O
do	O
not	O
have	O
access	O
to	O
information	O
such	O
as	O
usernames	O
,	O
passwords	O
,	O
or	O
cookies	O
sent	O
to	O
another	O
site	O
.	O
</s>
<s>
Most	O
JavaScript-related	O
security	O
bugs	O
are	O
breaches	O
of	O
either	O
the	O
same	B-Protocol
origin	I-Protocol
policy	I-Protocol
or	O
the	O
sandbox	O
.	O
</s>
<s>
There	O
are	O
subsets	O
of	O
general	O
JavaScript	B-Language
—	O
ADsafe	O
,	O
Secure	O
ECMAScript	B-Language
(	O
SES	O
)	O
—	O
that	O
provide	O
greater	O
levels	O
of	O
security	O
,	O
especially	O
on	O
code	O
created	O
by	O
third	O
parties	O
(	O
such	O
as	O
advertisements	O
)	O
.	O
</s>
<s>
Closure	B-Language
Toolkit	O
is	O
another	O
project	O
for	O
safe	O
embedding	O
and	O
isolation	O
of	O
third-party	O
JavaScript	B-Language
and	O
HTML	B-Language
.	O
</s>
<s>
Content	B-Protocol
Security	I-Protocol
Policy	I-Protocol
is	O
the	O
main	O
intended	O
method	B-Language
of	O
ensuring	O
that	O
only	O
trusted	O
code	O
is	O
executed	O
on	O
a	O
Web	O
page	O
.	O
</s>
<s>
A	O
common	O
JavaScript-related	O
security	O
problem	O
is	O
cross-site	O
scripting	O
(	O
XSS	O
)	O
,	O
a	O
violation	O
of	O
the	O
same-origin	B-Protocol
policy	I-Protocol
.	O
</s>
<s>
A	O
solution	O
to	O
XSS	O
vulnerabilities	O
is	O
to	O
use	O
HTML	B-Language
escaping	O
whenever	O
displaying	O
untrusted	O
data	O
.	O
</s>
<s>
Some	O
browsers	B-Application
include	O
partial	O
protection	O
against	O
reflected	O
XSS	O
attacks	O
,	O
in	O
which	O
the	O
attacker	O
provides	O
a	O
URL	O
including	O
malicious	O
script	O
.	O
</s>
<s>
However	O
,	O
even	O
users	O
of	O
those	O
browsers	B-Application
are	O
vulnerable	O
to	O
other	O
XSS	O
attacks	O
,	O
such	O
as	O
those	O
where	O
the	O
malicious	O
code	O
is	O
stored	O
in	O
a	O
database	O
.	O
</s>
<s>
Only	O
correct	O
design	O
of	O
Web	B-Application
applications	I-Application
on	O
the	O
server-side	B-Application
can	O
fully	O
prevent	O
XSS	O
.	O
</s>
<s>
XSS	O
vulnerabilities	O
can	O
also	O
occur	O
because	O
of	O
implementation	O
mistakes	O
by	O
browser	B-Application
authors	O
.	O
</s>
<s>
Another	O
cross-site	O
vulnerability	O
is	O
cross-site	B-Protocol
request	I-Protocol
forgery	I-Protocol
(	O
CSRF	B-Protocol
)	O
.	O
</s>
<s>
In	O
CSRF	B-Protocol
,	O
code	O
on	O
an	O
attacker	O
's	O
site	O
tricks	O
the	O
victim	O
's	O
browser	B-Application
into	O
taking	O
actions	O
the	O
user	O
did	O
not	O
intend	O
at	O
a	O
target	O
site	O
(	O
like	O
transferring	O
money	O
at	O
a	O
bank	O
)	O
.	O
</s>
<s>
In	O
general	O
,	O
the	O
solution	O
to	O
CSRF	B-Protocol
is	O
to	O
require	O
an	O
authentication	O
value	O
in	O
a	O
hidden	O
form	O
field	O
,	O
and	O
not	O
only	O
in	O
the	O
cookies	O
,	O
to	O
authenticate	O
any	O
request	O
that	O
might	O
have	O
lasting	O
effects	O
.	O
</s>
<s>
"	O
JavaScript	B-Language
hijacking	O
"	O
is	O
a	O
type	O
of	O
CSRF	B-Protocol
attack	I-Protocol
in	O
which	O
a	O
<script>	O
tag	O
on	O
an	O
attacker	O
's	O
site	O
exploits	O
a	O
page	O
on	O
the	O
victim	O
's	O
site	O
that	O
returns	O
private	O
information	O
such	O
as	O
JSON	B-General_Concept
or	O
JavaScript	B-Language
.	O
</s>
<s>
requiring	O
an	O
authentication	O
token	O
in	O
the	O
POST	B-Protocol
and	O
GET	O
parameters	O
for	O
any	O
response	O
that	O
returns	O
private	O
information	O
.	O
</s>
<s>
Developers	O
of	O
client-server	B-Operating_System
applications	B-Application
must	O
recognize	O
that	O
untrusted	O
clients	O
may	O
be	O
under	O
the	O
control	O
of	O
attackers	O
.	O
</s>
<s>
The	O
application	O
author	O
cannot	O
assume	O
that	O
their	O
JavaScript	B-Language
code	O
will	O
run	O
as	O
intended	O
(	O
or	O
at	O
all	O
)	O
because	O
any	O
secret	O
embedded	O
in	O
the	O
code	O
could	O
be	O
extracted	O
by	O
a	O
determined	O
adversary	O
.	O
</s>
<s>
Website	O
authors	O
cannot	O
perfectly	O
conceal	O
how	O
their	O
JavaScript	B-Language
operates	O
because	O
the	O
raw	O
source	O
code	O
must	O
be	O
sent	O
to	O
the	O
client	B-Protocol
.	O
</s>
<s>
JavaScript	B-Language
form	O
validation	O
only	O
provides	O
convenience	O
for	O
users	O
,	O
not	O
security	O
.	O
</s>
<s>
If	O
a	O
site	O
verifies	O
that	O
the	O
user	O
agreed	O
to	O
its	O
terms	O
of	O
service	O
,	O
or	O
filters	O
invalid	O
characters	O
out	O
of	O
fields	O
that	O
should	O
only	O
contain	O
numbers	O
,	O
it	O
must	O
do	O
so	O
on	O
the	O
server	O
,	O
not	O
only	O
the	O
client	B-Protocol
.	O
</s>
<s>
Scripts	O
can	O
be	O
selectively	O
disabled	O
,	O
so	O
JavaScript	B-Language
cannot	O
be	O
relied	O
on	O
to	O
prevent	O
operations	O
such	O
as	O
right-clicking	O
on	O
an	O
image	O
to	O
save	O
it	O
.	O
</s>
<s>
It	O
is	O
considered	O
very	O
bad	O
practice	O
to	O
embed	O
sensitive	O
information	O
such	O
as	O
passwords	O
in	O
JavaScript	B-Language
because	O
it	O
can	O
be	O
extracted	O
by	O
an	O
attacker	O
.	O
</s>
<s>
Package	B-Application
management	I-Application
systems	I-Application
such	O
as	O
npm	B-Language
and	O
Bower	O
are	O
popular	O
with	O
JavaScript	B-Language
developers	O
.	O
</s>
<s>
Such	O
systems	O
allow	O
a	O
developer	O
to	O
easily	O
manage	O
their	O
program	O
's	O
dependencies	O
upon	O
other	O
developers	O
 '	O
program	B-Library
libraries	I-Library
.	O
</s>
<s>
Developers	O
trust	O
that	O
the	O
maintainers	O
of	O
the	O
libraries	B-Language
will	O
keep	O
them	O
secure	O
and	O
up	O
to	O
date	O
,	O
but	O
that	O
is	O
not	O
always	O
the	O
case	O
.	O
</s>
<s>
Relied-upon	O
libraries	B-Language
can	O
have	O
new	O
releases	O
that	O
cause	O
bugs	O
or	O
vulnerabilities	O
to	O
appear	O
in	O
all	O
programs	O
that	O
rely	O
upon	O
the	O
libraries	B-Language
.	O
</s>
<s>
Inversely	O
,	O
a	O
library	B-Library
can	O
go	O
unpatched	O
with	O
known	O
vulnerabilities	O
out	O
in	O
the	O
wild	O
.	O
</s>
<s>
In	O
a	O
study	O
done	O
looking	O
over	O
a	O
sample	O
of	O
133,000	O
websites	O
,	O
researchers	O
found	O
37%	O
of	O
the	O
websites	O
included	O
a	O
library	B-Library
with	O
at	O
least	O
one	O
known	O
vulnerability	O
.	O
</s>
<s>
"	O
The	O
median	O
lag	O
between	O
the	O
oldest	O
library	B-Library
version	O
used	O
on	O
each	O
website	O
and	O
the	O
newest	O
available	O
version	O
of	O
that	O
library	B-Library
is	O
1,177	O
days	O
in	O
ALEXA	O
,	O
and	O
development	O
of	O
some	O
libraries	B-Language
still	O
in	O
active	O
use	O
ceased	O
years	O
ago.	O
"	O
</s>
<s>
Another	O
possibility	O
is	O
that	O
the	O
maintainer	O
of	O
a	O
library	B-Library
may	O
remove	O
the	O
library	B-Library
entirely	O
.	O
</s>
<s>
This	O
occurred	O
in	O
March	O
2016	O
when	O
Azer	O
Koçulu	O
removed	O
his	O
repository	O
from	O
npm	B-Language
.	O
</s>
<s>
This	O
caused	O
tens	O
of	O
thousands	O
of	O
programs	O
and	O
websites	O
depending	O
upon	O
his	O
libraries	B-Language
to	O
break	O
.	O
</s>
<s>
JavaScript	B-Language
provides	O
an	O
interface	O
to	O
a	O
wide	O
range	O
of	O
browser	B-Application
capabilities	O
,	O
some	O
of	O
which	O
may	O
have	O
flaws	O
such	O
as	O
buffer	B-General_Concept
overflows	I-General_Concept
.	O
</s>
<s>
This	O
code	O
is	O
not	O
by	O
any	O
means	O
limited	O
to	O
another	O
JavaScript	B-Language
application	O
.	O
</s>
<s>
For	O
example	O
,	O
a	O
buffer	B-General_Concept
overrun	I-General_Concept
exploit	O
can	O
allow	O
an	O
attacker	O
to	O
gain	O
access	O
to	O
the	O
operating	O
system	O
's	O
API	B-General_Concept
with	O
superuser	O
privileges	O
.	O
</s>
<s>
These	O
flaws	O
have	O
affected	O
major	O
browsers	B-Application
including	O
Firefox	B-Application
,	O
Internet	B-Application
Explorer	I-Application
,	O
and	O
Safari	O
.	O
</s>
<s>
Plugins	O
,	O
such	O
as	O
video	O
players	O
,	O
Adobe	O
Flash	O
,	O
and	O
the	O
wide	O
range	O
of	O
ActiveX	B-Application
controls	I-Application
enabled	O
by	O
default	O
in	O
Microsoft	B-Application
Internet	I-Application
Explorer	I-Application
,	O
may	O
also	O
have	O
flaws	O
exploitable	O
via	O
JavaScript	B-Language
(	O
such	O
flaws	O
have	O
been	O
exploited	O
in	O
the	O
past	O
)	O
.	O
</s>
<s>
In	O
Windows	O
Vista	O
,	O
Microsoft	O
has	O
attempted	O
to	O
contain	O
the	O
risks	O
of	O
bugs	O
such	O
as	O
buffer	B-General_Concept
overflows	I-General_Concept
by	O
running	O
the	O
Internet	B-Application
Explorer	I-Application
process	O
with	O
limited	O
privileges	O
.	O
</s>
<s>
Google	B-Application
Chrome	I-Application
similarly	O
confines	O
its	O
page	O
renderers	O
to	O
their	O
own	O
"	O
sandbox	O
"	O
.	O
</s>
<s>
Web	B-Application
browsers	I-Application
are	O
capable	O
of	O
running	O
JavaScript	B-Language
outside	O
the	O
sandbox	O
,	O
with	O
the	O
privileges	O
necessary	O
to	O
,	O
for	O
example	O
,	O
create	O
or	O
delete	O
files	O
.	O
</s>
<s>
Incorrectly	O
granting	O
privileges	O
to	O
JavaScript	B-Language
from	O
the	O
Web	O
has	O
played	O
a	O
role	B-General_Concept
in	O
vulnerabilities	O
in	O
both	O
Internet	B-Application
Explorer	I-Application
and	O
Firefox	B-Application
.	O
</s>
<s>
In	O
Windows	O
XP	O
Service	O
Pack	O
2	O
,	O
Microsoft	O
demoted	O
JScript	B-Language
's	O
privileges	O
in	O
Internet	B-Application
Explorer	I-Application
.	O
</s>
<s>
Microsoft	B-Application
Windows	I-Application
allows	O
JavaScript	B-Language
source	O
files	O
on	O
a	O
computer	O
's	O
hard	O
drive	O
to	O
be	O
launched	O
as	O
general-purpose	O
,	O
non-sandboxed	O
programs	O
(	O
see	O
:	O
Windows	O
Script	O
Host	O
)	O
.	O
</s>
<s>
This	O
makes	O
JavaScript	B-Language
(	O
like	O
VBScript	B-Application
)	O
a	O
theoretically	O
viable	O
vector	O
for	O
a	O
Trojan	O
horse	O
,	O
although	O
JavaScript	B-Language
Trojan	O
horses	O
are	O
uncommon	O
in	O
practice	O
.	O
</s>
<s>
In	O
2015	O
,	O
a	O
JavaScript-based	O
proof-of-concept	O
implementation	O
of	O
a	O
rowhammer	B-General_Concept
attack	O
was	O
described	O
in	O
a	O
paper	O
by	O
security	O
researchers	O
.	O
</s>
<s>
In	O
2017	O
,	O
a	O
JavaScript-based	O
attack	O
via	O
browser	B-Application
was	O
demonstrated	O
that	O
could	O
bypass	O
ASLR	O
.	O
</s>
<s>
In	O
2018	O
,	O
the	O
paper	O
that	O
announced	O
the	O
Spectre	B-Error_Name
attacks	I-Error_Name
against	O
Speculative	O
Execution	O
in	O
Intel	O
and	O
other	O
processors	O
included	O
a	O
JavaScript	B-Language
implementation	O
.	O
</s>
<s>
Every	O
major	O
web	B-Application
browser	I-Application
has	O
built-in	O
web	B-Application
development	I-Application
tools	I-Application
,	O
including	O
a	O
JavaScript	B-Language
debugger	I-Language
.	O
</s>
<s>
Static	O
program	O
analysis	O
tools	O
,	O
such	O
as	O
ESLint	B-Language
and	O
JSLint	B-Language
,	O
scan	O
JavaScript	B-Language
code	O
for	O
conformance	O
to	O
a	O
set	O
of	O
standards	O
and	O
guidelines	O
.	O
</s>
<s>
Some	O
browsers	B-Application
have	O
built-in	O
profilers	O
.	O
</s>
<s>
Stand-alone	O
profiling	O
libraries	B-Language
have	O
also	O
been	O
created	O
,	O
such	O
as	O
benchmark.js	O
and	O
jsbench	O
.	O
</s>
<s>
Many	O
text	B-Application
editors	I-Application
have	O
syntax	O
highlighting	O
support	O
for	O
JavaScript	B-Language
code	O
.	O
</s>
<s>
A	O
common	O
misconception	O
is	O
that	O
JavaScript	B-Language
is	O
the	O
same	O
as	O
Java	B-Language
.	O
</s>
<s>
Both	O
indeed	O
have	O
a	O
C-like	O
syntax	O
(	O
the	O
C	B-Language
language	I-Language
being	O
their	O
most	O
immediate	O
common	O
ancestor	O
language	O
)	O
.	O
</s>
<s>
They	O
are	O
also	O
typically	O
sandboxed	O
(	O
when	O
used	O
inside	O
a	O
browser	B-Application
)	O
,	O
and	O
JavaScript	B-Language
was	O
designed	O
with	O
Java	B-Language
's	O
syntax	O
and	O
standard	B-Library
library	I-Library
in	O
mind	O
.	O
</s>
<s>
In	O
particular	O
,	O
all	O
Java	B-Language
keywords	O
were	O
reserved	O
in	O
original	O
JavaScript	B-Language
,	O
JavaScript	B-Language
's	O
standard	B-Library
library	I-Library
follows	O
Java	B-Language
's	O
naming	O
conventions	O
,	O
and	O
JavaScript	B-Language
's	O
and	O
objects	O
are	O
based	O
on	O
classes	O
from	O
Java	B-Language
1.0	O
.	O
</s>
<s>
Java	B-Language
and	O
JavaScript	B-Language
both	O
first	O
appeared	O
in	O
1995	O
,	O
but	O
Java	B-Language
was	O
developed	O
by	O
James	O
Gosling	O
of	O
Sun	O
Microsystems	O
and	O
JavaScript	B-Language
by	O
Brendan	O
Eich	O
of	O
Netscape	B-Protocol
Communications	O
.	O
</s>
<s>
Java	B-Language
has	O
static	O
typing	O
,	O
while	O
JavaScript	B-Language
's	O
typing	O
is	O
dynamic	O
.	O
</s>
<s>
Java	B-Language
is	O
loaded	O
from	O
compiled	B-Language
bytecode	O
,	O
while	O
JavaScript	B-Language
is	O
loaded	O
as	O
human-readable	O
source	O
code	O
.	O
</s>
<s>
Java	B-Language
's	O
objects	O
are	O
class-based	B-Application
,	O
while	O
JavaScript	B-Language
's	O
are	O
prototype-based	B-Application
.	O
</s>
<s>
Finally	O
,	O
Java	B-Language
did	O
not	O
support	O
functional	B-Language
programming	I-Language
until	O
Java	B-Language
8	O
,	O
while	O
JavaScript	B-Language
has	O
done	O
so	O
from	O
the	O
beginning	O
,	O
being	O
influenced	O
by	O
Scheme	B-Language
.	O
</s>
<s>
JSON	B-General_Concept
,	O
or	O
JavaScript	B-General_Concept
Object	I-General_Concept
Notation	I-General_Concept
,	O
is	O
a	O
general-purpose	O
data	O
interchange	O
format	O
that	O
is	O
defined	O
as	O
a	O
subset	O
of	O
JavaScript	B-Language
's	O
object	O
literal	O
syntax	O
.	O
</s>
<s>
TypeScript	B-Language
(	O
TS	O
)	O
is	O
a	O
strictly-typed	O
variant	O
of	O
JavaScript	B-Language
.	O
</s>
<s>
Otherwise	O
TS	O
shares	O
much	O
the	O
same	O
featureset	O
as	O
JS	O
,	O
to	O
allow	O
it	O
to	O
be	O
easily	O
transpiled	B-Language
to	O
JS	O
for	O
running	O
client-side	B-Operating_System
,	O
and	O
to	O
interoperate	O
with	O
other	O
JS	O
code	O
.	O
</s>
<s>
Since	O
2017	O
,	O
web	B-Application
browsers	I-Application
have	O
supported	O
WebAssembly	B-Language
,	O
a	O
binary	O
format	O
that	O
enables	O
a	O
JavaScript	B-Language
engine	I-Language
to	O
execute	O
performance-critical	O
portions	O
of	O
web	O
page	O
scripts	O
close	O
to	O
native	O
speed	O
.	O
</s>
<s>
WebAssembly	B-Language
code	O
runs	O
in	O
the	O
same	O
sandbox	O
as	O
regular	O
JavaScript	B-Language
code	O
.	O
</s>
<s>
asm.js	B-Language
is	O
a	O
subset	O
of	O
JavaScript	B-Language
that	O
served	O
as	O
the	O
forerunner	O
of	O
WebAssembly	B-Language
.	O
</s>
<s>
JavaScript	B-Language
is	O
the	O
dominant	O
client-side	B-Operating_System
language	O
of	O
the	O
Web	O
,	O
and	O
many	O
websites	O
are	O
script-heavy	O
.	O
</s>
<s>
Thus	O
transpilers	B-Language
have	O
been	O
created	O
to	O
convert	O
code	O
written	O
in	O
other	O
languages	O
,	O
which	O
can	O
aid	O
the	O
development	O
process	O
.	O
</s>
