JavaScript:
Basics, Coercion, Functions
Computer Science and Engineering College of Engineering The Ohio State University
Copyright By PowCoder代写 加微信 powcoder
Developed by Netscape
“LiveScript”, then renamed “JavaScript” Nothing to do with Java!
Interpreted
Browser-based, client-side execution Standardized by ECMA (“ECMAScript”)
But no one calls it that! MIME type text/javascript
cf., JScript (MS)
Becoming popular outside of browsers
e.g. Node.js
Translation target for other languages:
Syntax: CoffeeScript
Static types: Dart (Google), TypeScript (MS)
Computer Science and Engineering The Ohio State University
Client-Side Execution
Computer Science and Engineering The Ohio State University
GET /news/index.php HTTP/1.1
Host: www.osu.edu
User-Agent: Mozilla/5.0 (X11; Ubuntu;…etc
Client-Side Execution
Computer Science and Engineering The Ohio State University
Hello World!
Client-Side Execution
Computer Science and Engineering The Ohio State University
window.alert(“Annoying!”);
Hello World!
Including Scripts
Head: executed before body displays
Script (source) can be explicitly included
Recall: linking to CSS
Inline: executed as body is displayed
Browser blocks while downloading
Common advice: put scripts at end of body Modern advice: use