Javascript
Javascript
Javascript
What is JavaScript?
• JavaScript was introduced in 1995 as a way to add programs to web
pages in the Netscape Navigator browser
• JavaScript was initially created to “make web pages alive”
• The programs in this language are called scripts
• They can be written right in a web page’s HTML and executed
automatically as the page loads.
• Scripts are provided and executed as plain text. They don’t need
special preparation or compilation to run.
• In this aspect, JavaScript is very different from another language
called Java.
Why JavaScript?
• When JavaScript was created, it initially had another name:
“LiveScript”. But Java was very popular at that time, so it was decided
that positioning a new language as a “younger brother” of Java would
help.
• But as it evolved, JavaScript became a fully independent language
with its own specification called ECMAScript, and now it has no
relation to Java at all.
What can in-browser JavaScript do?
• Add new HTML to the page, change the existing content, modify
styles.
• React to user actions, run on mouse clicks, pointer movements, key
presses.
• Send requests over the network to remote servers, download and
upload files (AJAX).
• Get and set cookies, ask questions to the visitor, show messages.
• Remember the data on the client-side (“local storage”).
What CAN’T in-browser JavaScript do?
• JavaScript on a webpage may not read/write arbitrary files on the
hard disk, copy them or execute programs. It has no direct access to
OS system functions.
• Different tabs/windows generally do not know about each other
• JavaScript can easily communicate over the net to the server where
the current page came from. But its ability to receive data from other
sites/domains is crippled
What CAN’T in-browser JavaScript do?
• Such limits do not exist if JavaScript is used outside of the browser, for
example on a server
• Modern browsers also allow plugin/extensions which may ask for
extended permissions.
What makes JavaScript unique?
• Full integration with HTML/CSS.
• Simple things are done simply.
• Support by all major browsers and enabled by default.
Code editors