the javascript language BY SA.

Slides:



Advertisements
Similar presentations
The JavaScript Programming Language
Advertisements

The Web Wizards Guide To JavaScript Chapter 1 JavaScript Basics.
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Intro to Javascript CS Client Side Scripting CS380 2.
Molecular Biomedical Informatics Web Programming 1.
Powerpoint Templates Page 1 Powerpoint Templates Server Side Scripting PHP.
the c language BY SA 1972 by Ken Thompson and Dennis Ritchie.
Introducing JavaScript
the java language BY SA introduced in 1995 by Sun Microsystems.
Intro to JavaScript. JavaScript History Client (generally browser-side) language invented at Netscape under the name LiveScript around 1995 Netscape wanted.
1 COMM 1213 H1 COMP 4923 X1 JavaScript 1 (Readings: Ch. 10, 11 Knuckles)
JavaScript Part 6. Calling JavaScript functions on an event JavaScript doesn’t have a main function like other programming languages but we can imitate.
1 CSC 551: Web Programming Spring 2004 client-side programming with JavaScript  scripts vs. programs  JavaScript vs. JScript vs. VBScript  common tasks.
JavaScript: JS301 Week 1: An Introduction to JavaScript.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
Javascript Client-side scripting. Up to now  We've seen a little about how to control  content with HTML  presentation with CSS  Javascript is a language.
Kevin Reuter & Brian Guthrie.  Multi-paradigm  Prototype based objects  Dynamic, weak typing.
Tutorial 10 Programming with JavaScript
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
Introduction to Web Site Development Steven Emory Department of Computer Science California State University, Los Angeles Lecture 8: JavaScript I.
Chapter 6 DOJO TOOLKITS. Objectives Discuss XML DOM Discuss JSON Discuss Ajax Response in XML, HTML, JSON, and Other Data Type.
PHP Overview CS PHP PHP = PHP: Hypertext Preprocessor Server-side scripting language that may be embedded into HTML One goal is to get PHP files.
4.1 JavaScript Introduction
1 Introduction to PHP. 2 What is this “PHP” thing? Official description: “PHP, which stands for "PHP: Hypertext Preprocessor" is a widely-used Open Source.
JavaScript JavaScript is a scripting language that is most commonly used to add client- side programming to a web page. Some of the things it is used for.
Programming with JavaScript (Chapter 10). XP Various things Midterm grades: Friday Winter Career Fair – Thursday, April 28, 2011 (11 am to 3 pm). – MAC.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
CISC474 - JavaScript 03/02/2011. Some Background… Great JavaScript Guides: –
Arrays – What is it? – Creation – Changing the contents Functions – What is it? – Syntax – How they work – Anonymous functions A quick lesson in Objects.
Week 9 PHP Cookies and Session Introduction to JavaScript.
Javascript. Outline Introduction Fundamental of JavaScript Javascript events management DOM and Dynamic HTML (DHTML)
JavaScript davide morelli history LiveScript (1995) in Netscape java script is a misleading name started as a scripting counterpart.
1 JavaScript in Context. Server-Side Programming.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
Tutorial 10 Programming with JavaScript. XP Objectives Learn the history of JavaScript Create a script element Understand basic JavaScript syntax Write.
CHAPTER 4 Java Script อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา 1.
Using Client-Side Scripts to Enhance Web Applications 1.
Lecture 9 The Basics of JavaScript Boriana Koleva Room: C54
Java Script: Arrays (Chapter 11 in [2]). 2 Outline Introduction Introduction Arrays Arrays Declaring and Allocating Arrays Declaring and Allocating Arrays.
JavaScript, jQuery, and Mashups Incorporating JavaScript, jQuery, and other Mashups into existing pages.
JS Basics 1 Lecture JavaScript - Basics. JS Basics 2 What is JavaScript JavaScript is a “simple”, interpreted, programming language with elementary object-
JavaScript Justin Skinner Programming Languages. JavaScript JavaScript is not Java nor a subset But JavaScript does share the C-family syntax with Java.
Javascript. What is JavaScript? Scripting (interpreted) language designed for the web Beware: JavaScript is case sensitive.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
Scott Marino MSMIS Summer Session Web Site Design and Authoring Session 8 Scott Marino.
05 – Java Script (1) Informatics Department Parahyangan Catholic University.
(1) JavaScript. (2) JavaScript vs. Java JavaScript and Java are completely different Java, invented by Sun in 1995, is a complex programming language.
1 JavaScript in Context. Server-Side Programming.
Pertemuan 5 IT133 Pengembangan Web JavaScript. What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting.
1 JavaScript 2.0: Evolving a Language for Evolving Systems Waldemar Horwat Netscape.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Introduction to Javascript. What is javascript?  The most popular web scripting language in the world  Used to produce rich thin client web applications.
JavaScript and Ajax Week 10 Web site:
JavaScript and AJAX 2nd Edition Tutorial 1 Programming with JavaScript.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
INTERNET APPLICATIONS CPIT405 JavaScript Instructor: Rasha AlOmari
AJAX. Objectives Understand and apply AJAX Using AJAX in DOJO library.
Javascript Prof. Wenwen Li School of Geographical Sciences and Urban Planning 5644 Coor Hall
CS5220 Advanced Topics in Web Programming JavaScript and jQuery
Web Systems Development (CSC-215)
T. Jumana Abu Shmais – AOU - Riyadh
CS5220 Advanced Topics in Web Programming JavaScript Basics
University of Kurdistan
Tutorial 10 Programming with JavaScript
CS3220 Web and Internet Programming JavaScript Basics
JavaScript CS 4640 Programming Languages for Web Applications
CS3220 Web and Internet Programming JavaScript Basics
JavaScript CS 4640 Programming Languages for Web Applications
Presentation transcript:

the javascript language

BY SA

Javascript is not Java

Brendan Eich at Netscape in 1995 named in deal between Netscape and Sun ECMA standard calls it ECMAScript

only language in all modern web browsers currently focus of lots of optimization work

the DOM (Document Object Model, the hierarchy of objects representing page content in web browsers) AJAX (Asynchronous Javascript and XML, a technique to submit/request data without refreshing the page)

dynamic and (a little) functional object-oriented programming via prototyping

numbers booleans strings arrays (lists) objects (dictionaries) functions null

+ addition - subtraction/negation / division *multiplication %modulus

x * ((x * 3) + 9) (+ (* x 3) 9)

foo(a, b, c) bar() (foo a b c) (bar)

foo (foo) ((foo)) foo foo() (foo()) (foo)

foo = bar / 2 (foo = (bar / 2)) (= foo (/ bar 2)) lvalue rvalue

x = y = z = (x = (y = (z = (4 + 2)))) (((x = y) = z) = (4 + 2)) the = operator is right-to-left associative

x = 3; cow = 2 + x; foo(1); rat = bar();

free-form syntax x = 3; x = 3 ;

foo(); // ignore this /* ignore all this too */ bar();

/* apple /* banana orange */ lemon */

_foo foo_bar $foo foo$bar

var var name; var name = expression; var monkey; var zebra = 3;

var jeff; foo(jeff); // OK foo(amanda); // error undefined

function function(parameters) {body}

! not === equals !== not equals &&and ||or < less than > greater than <= less than or equal >= greater than or equal

!true// false !false// true !null// true !0// true !“”// true !undefined// true

3 === 3// true 3 === -2// false !true === false// true

(3 === 3) || (2 > 4) // true

if / else if (condition) {body} else if (condition) {body} else {body} while while (condition) {body}

if (x === 3) { foo(); } else { bar(); }

var i = 0; while (i < 5) { foo(); i = i + 1; }

var foo = function() { return bar; }; foo(); // error var bar = 3; foo(); // OK

var foo = function() { bar = 6; return bar; var bar; }; foo(); // 6

nested functions

AC AD B E B AD CB C

closure

objects {properties} object[string]

var foo = {}; var bar = {“bill”: 1 + 1, “diana”: 11}; var ack = bar[“bill”]; // 2 bar[“bill”] = 3; foo[“ned”] = 8; ack = foo[“ted”]; // undefined

var foo = {}; var bar = {bill: 1 + 1, diana: 11}; var ack = bar.bill; // 2 bar.bill = 3; foo.ned = 8; ack = foo.ted; // undefined

methods var foo = {}; foo.bar = function() { this.ack = 3; }; foo.bar();

var foo = {}; foo.bar = function(x) { x.ack = 3; }; foo.bar(foo);

var foo = {}; foo.bar = function() { this = 3; //error }; foo.bar();

var bar = function() { return this; }; bar(); // global object passed to this

object links AC AD B E B AD CB C

var foo = {a: 1, b: 2, c: 3}; var bar = {a: 4, d: 5}; var ack = {b: 6, e: 7}; … // foo  bar  ack var x = foo.c === bar.c === ack.c; // true bar.c = 8; x = ack.c; // 8 x = foo.c; // 3

var foo = “hello”; var x = foo.length; // 5 x = foo.charAt(1) ; // “e” x = “avast”.charAt(3) ; // “s”

charAt lengthcharAtlengthcharAt

var Tom = function(foo, bar) { this.foo = foo; this.bar = bar; }; var jane = (new Tom(2, 3)); var david = new Tom(7, 10);

var Tom = function(foo, bar) { this.foo = foo; this.bar = bar; }; Tom.prototype.ack = “hello”; var jane = new Tom(2, 3); var x = jane.ack; // “hello” ack foo ack bar

arrays [items] array[index]

var foo = []; var bar = [4, “hello”, 33]; var ack = bar[2]; // 33 bar[3] = “orange”;

var foo = []; var bar = [4, “hello”, 33]; var ack = bar[“2”]; // 33 bar[“3”] = “orange”;

var foo = []; var bar = [4, “hello”, 33]; var ack = foo.length; // 0 ack = bar.length; // 3 bar[15] = true; ack = bar.length; // 16 ack = bar[8]; // undefined

arguments var foo = function(a, b, c) { // arguments[0] equals a // arguments[1] equals b // arguments[2] equals c … };

var foo = function(a, b, c) { … }; foo(1, 7, 11, 2, 8); // OK foo(6, 7); // OK

var sum = function() { var i = 0; var sum = 0; while (i < arguments.length) { sum = sum + arguments[i]; i = i + 1; } return sum; }; sum(2, 2, 3); // 7 sum(5, 7); // 12 sum(); // 0

exceptions foo(“hello” * true);

exceptions try { foo(“hello” * true); bar(); } catch (ex) { ack(ex); }

try { throw “We’re screwed.”; bar(); } catch (ex) { ack(ex); }

var foo = function () { … // exception }; foo(); // exception

try { foo(); // exception bar(); } catch (ex) { ack(); }

var bar = function() { try { foo(); // exception } catch (ex) { ack(); } foo(); // exception }; bar(); // exception