Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

JavaScript - Web Programming - Lecture Slides, Slides of Computer Programming

If you are looking for Web Programming course, you are at right place. This lecture key words are: Javascript, Javascript Background, Purpose of Javascript, Javascript Syntax, History Lesson, Dynamic Html, Client Side Data Entry Validation, Client Side Cgi, Process and Manage Cookies, Creating a First Script

Typology: Slides

2012/2013

Uploaded on 09/27/2013

vikrant
vikrant 🇮🇳

4.4

(9)

130 documents

1 / 56

Toggle sidebar

Related documents


Partial preview of the text

Download JavaScript - Web Programming - Lecture Slides and more Slides Computer Programming in PDF only on Docsity!

JavaScript

Part 1

Lecture Overview

 JavaScript background  The purpose of JavaScript  JavaScript syntax

History Lesson

 JavaScript is NOT Java  Started at Netscape in 1995  Microsoft released its own version 'JScript" in 1996  JavaScript is the default scripting language in .NET (VBScript has pretty much faded away)

What do we do with

JavaScript?

 A starter list  Adds sizzle to pages (Animation)  Dynamic HTML (DHTML)  Client side data entry validation  Client side CGI  Reduce the load on overburdened servers  Process and manage cookies  Some servers are beginning to support JavaScript  AJAX to load parts of Web pages

What is JavaScript? (1)

 It‟s a programming language that „closely‟ resembles Java  Implementations  European Computer Manufacturers Association created ECMAScript to standardize different scripting versions See ECMA-  I‟ll try to conform  There are others  It‟s a “C ish” language

What is JavaScript (2)

 Most of what we do is access the object model supported by the underlying browser  The W3C defines the Document Object Model (DOM)  Differences do exist between browsers  I will try, where possible, to point out these differences  Most support the common ECMA standards though

Creating a First Script

**

Creating a First Script

**

**

script tag

Script tag

Script language

Script Placement (1)

 A document may have multiple

JavaScript is not enabled.

**

JavaScript IS

CASE

SENSITIVE

JavaScript Semantics

 Semicolons need not terminate statements although they do no harm  Unless two statements are placed on the same line  Variables  var data type is generic  JavaScript is not strongly typed like Java  Type conversion happens on the fly  Other types  number , boolean , string , function , object

Creating a First Script

(Example)

 See JavaScriptExample1.htm

 Pay particular attention to the order in which the script code executes

Comments

 Comments appear differently inside of JavaScript block that outside of a JavaScript block  The characters // on a line mark the line as a comment  The strings /* and */ mark the begin and end of a multi-line comment

Adding Comments

**

**

Variables (1)

 JavaScript is “loosely typed‟  data types change dynamically as the program runs  Declare variables with the var statement

Variables (2)

 Examples

var x // Now x is undefined var x = 5; // Now x is a Number var x = "John"; // Now x is a String

Variables (3)

 Like VB, there are local and global variables  Local variables are declared inside of a procedure  Global variables are declared in a **

Calling a Function

 Functions execute when called  Call functions explicitly from other JavaScript code  Call functions implicitly from an event handler

Calling a Function (Exampple)

 From another function or from within another JavaScript block, call the function with it‟s name an parameters

 Example: ****

Returning a

Value from a Function

 Call the return statement with an argument as in

return 0;