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

Exploring Java Script - Introduction to Java Script - Lecture Slides, Slides of Javascript programming

Here is my collection on JavaScript lectures. It includes tutorials as well as general concepts explanations. Particularly these slides contain: Exploring Java Script, Low-Level Print, Document, Html Tag, Syntax Errors, Seeing the Error, Console Logging, Variable Names, Assignment Operators, Determining Type

Typology: Slides

2013/2014

Uploaded on 01/29/2014

surii
surii 🇮🇳

3.5

(13)

130 documents

1 / 48

Toggle sidebar

Related documents


Partial preview of the text

Download Exploring Java Script - Introduction to Java Script - Lecture Slides and more Slides Javascript programming in PDF only on Docsity!

Exploring JavaScript

Hello</h2> <h2>World

One

Paragraph

disabled JavaScript.

Second

Paragraph

js-01.htm

Low-Level Print

• When in doubt, you can always add an to your JavaScript

• The alert() function takes a string as a parameter and pauses the

JavaScript execution until you press "OK"

Hello World

One Paragraph

Second Paragraph

js-02.htm

Including JavaScript

• Three Patterns

• As part of an event (i.e. onclick) in an HTML tag

• Inline within the document

• From a file

Hello World

One Paragraph

Click Me

Third Paragraph

JavaScript on a tag

js-03.htm

Hello</h2> <h2>World

One

Paragraph

Second

Paragraph

JavaScript inline that

will pass validation

Hello World

One Paragraph

Third Paragraph

script.js: document.write("

Hello World

");

JavaScript in a

separate file

js-04.htm

Syntax Errors

• Like any language, we can make syntax errors

• By default, browsers silently eat any kind of JavaScript error

• But the code stops running in that file or script section

One Paragraph

Two Paragraph

Three Paragraph

js-05.htm

Seeing the Error

• Since the end-user really cannot take any action to fix the

JavaScript coming as part of a web page, the browser eats the errors.

• As a developer, we need to look for the errors - sometimes it takes

a minute to even remember to check for a JS error

Console Logging

• Debugging using alert() can get tiring - sometimes you want to

record what happens in case something goes wrong

• http://getfirebug.com/logging

• console.log("String") - and many more functions

• Note: Requires recent browsers

One Paragraph

Two Paragraph

Three Paragraph

js-06.htm

Console is Not Always There

• Some browsers only define the console if a debugger is

running window.console && console.log(...) if (typeof console == "undefined") { this.console = {log: function() {} } http://stackoverflow.com/questions/3326650/console-is-undefined-error-for-internet- explorer

Using the Debugger

• Add the FireBug FireFox Extension

• Enable FireBug, reload

• Set Breakpoint, and reload again

JavaScript Language

Comments in JavaScript =

Awesome

// This is a comment /* This is a section of multiline comments that will not be interpreted */

Statements

• White space and newlines do not matter

• Statements end with semicolon ;

• There are cases where you can the semicolon off - but don't

bother exploiting the feature - just add semicolons like C, Java, PHP, C++, etc..

One Paragraph

Second Paragraph

js-07.htm

Variable Names

• Valid Characters: a-z, A-Z, 0-9, _ and $

• Must not start with a number

• Names are case sensitive

• Starting with a dollar sign is considered "tacky"