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

Lesson 1 Introduction To JavaScript

JavaScript was created by Brendan Eich to make web pages interactive. It can execute in browsers as well as servers and other devices. JavaScript engines parse, compile, and run scripts to add interactivity to web pages. While JavaScript can modify pages and interact with users, it has limited access to files and other domains for security reasons. Many languages have emerged that transpile to JavaScript to provide different features, but knowledge of JavaScript is still important.

Uploaded by

Jaja Arcenal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
116 views

Lesson 1 Introduction To JavaScript

JavaScript was created by Brendan Eich to make web pages interactive. It can execute in browsers as well as servers and other devices. JavaScript engines parse, compile, and run scripts to add interactivity to web pages. While JavaScript can modify pages and interact with users, it has limited access to files and other domains for security reasons. Many languages have emerged that transpile to JavaScript to provide different features, but knowledge of JavaScript is still important.

Uploaded by

Jaja Arcenal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Introduction to JavaScript Page 1 of 2

What is JavaScript?

 JavaScript was developed by Brendan Eich.


 Originally the language was called Live Script.
 JavaScript was initially created to “make web pages alive”.
 The programs written in this language are called scripts.
o Scripts can be written right in a web page’s HTML and run automatically as the page loads.
o Scripts are provided and executed as plain text (no special preparation or compilation to run).
 Today, JavaScript can execute not only in the browser, but also on the server, or actually on any
device that has a special program called the JavaScript engine.

JavaScript engine names:

 V8 – in Chrome and Opera.


 SpiderMonkey – in Firefox.
 …There are other codenames like “Trident” and “Chakra” for different versions of IE,
“ChakraCore” for Microsoft Edge, “Nitro” and “SquirrelFish” for Safari, etc.

How do engines work?

1. The engine (embedded if it’s a browser) reads (“parses”) the script.


2. Then it converts (“compiles”) the script to the machine language.
3. And then the machine code runs, pretty fast.

What JavaScript can do?

 Add new HTML to the page, change the existing content, and modify styles.
 React to user actions, run on mouse clicks, pointer movements, and key presses.
 Send requests over the network to remote servers, download and upload files (so-called AJAX and
COMET technologies).
 Validate form data entered by the user.
 Get and set cookies, ask questions to the visitor, show messages.
 Remember the data on the client-side (“local storage”).

What JavaScript can’t 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.
o Modern browsers allow it to work with files, but the access is limited and only provided if the
user does certain actions, like “dropping” a file into a browser window or selecting it via an
<input> tag.
 JavaScript from one page may not access the other if they come from different sites (from a different
domain, protocol or port).
 JavaScript ability to receive data from other sites/domains is crippled (Though possible, it requires
explicit agreement (expressed in HTTP headers) from the remote side.)

Note: 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?

Lesson 1  jyercia
Introduction to JavaScript Page 2 of 2

 Full integration with HTML/CSS.


 Simple things are done simply.
 Support by all major browsers and enabled by default.

Languages “over” JavaScript

The syntax of JavaScript does not suit everyone’s needs. Different people want different features.

That’s to be expected, because projects and requirements are different for everyone.

So recently a plethora of new languages appeared, which are transpiled (converted) to JavaScript before
they run in the browser.

Modern tools make the transpilation very fast and transparent, actually allowing developers to code in
another language and auto-converting it “under the hood”.

Examples of such languages:

 CoffeeScript is a “syntactic sugar” for JavaScript. It introduces shorter syntax, allowing us to write
clearer and more precise code. Usually, Ruby devs like it.
 TypeScript is concentrated on adding “strict data typing” to simplify the development and support
of complex systems. It is developed by Microsoft.
 Dart is a standalone language that has its own engine that runs in non-browser environments (like
mobile apps). It was initially offered by Google as a replacement for JavaScript, but as of now,
browsers require it to be transpiled to JavaScript just like the ones above.

There are more. Of course, even if we use one of these languages, we should also know JavaScript to really
understand what we’re doing.

Summary

 JavaScript was initially created as a browser-only language, but is now used in many other
environments as well.
 Today, JavaScript has a unique position as the most widely-adopted browser language with full
integration with HTML/CSS.
 There are many languages that get “transpiled” to JavaScript and provide certain features. It is
recommended to take a look at them, at least briefly, after mastering JavaScript.

Lesson 1  jyercia

You might also like