- 1995; Brendan Eich created in 10 days
- Netscape Navigator
- Copied into IE as "JScript"
- JavaScript is not Java
- It is a completely different language
- AKA "ECMAScript"
- Inspired by LISP, particularly Scheme
- Functions as first-class objects
- Optional arguments
- Loose typing
- Closure
- Tail recursion (coming soon!)
- C syntax
- Web & mobile apps
- Browser plugins
- Servers
- Click F12 (Cmd+Option+I on Mac)
- Choose "console"
- Create a folder called
project\ - Open Notepad
- Create and save each of the following files
- Be careful NOT to save as ".txt"! Choose "Save as type:" > "All files" and specify the file extensions.
project\index.html:
<script src="index.js"></script>project\index.js:
console.log('Hello World!');- Open
project\folder, right-click onindex.html - Choose "Open with" > "Google Chrome"
- Click F12 and choose "console"
- Download Node.js
- Open command line ("cmd")
cd Downloads
node.exe
> console.log('hello world')
hello world
undefined- Type "Ctrl+C" to exit.
- Open Notepad
- Create and save each of the following files
project\server.js:
var http = require('http');
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://localhost:1337/');- Open command line again
node.exe server.js
Server running at http://localhost:1337/- Open a web browser and navigate to
http://localhost:1337/