An Introduction to JavaScript

Slides:



Advertisements
Similar presentations
Chapter 7 JavaScript: Introduction to Scripting. Outline Simple Programs Objects and Variables Obtaining User Input with prompt Dialogs – –Dynamic Welcome.
Advertisements

JavaScript Objects - DOM CST 200 JavaScript. Objectives Introduce JavaScript objects Introduce Document Object Model Introduce window object Introduce.
Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
The Web Warrior Guide to Web Design Technologies
1 Outline 13.1Introduction 13.2A Simple Program: Printing a Line of Text in a Web Page 13.3Another JavaScript Program: Adding Integers 13.4Memory Concepts.
Information Technology Center Hany Abdelwahab Computer Specialist.
Introduction to scripting
JavaScript: Control Structures September 27, 2005 Slides modified from Internet & World Wide Web: How to Program (3rd) edition. By Deitel, Deitel,
WEB DESIGN AND PROGRAMMING Introduction to Javascript.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
DHTML: Dynamic HTML Internet Technology1. What is DHTML? A collection of enhancements to HTML ► To create dynamic and interactive websites Combination.
What is Java Script? An extension to HTML. An extension to HTML. Allows authors to incorporate some functionality in their web pages. (without using CGI.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
Introduction to JavaScript Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan. 1.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Introduction.  The scripting language most often used for client-side web development.  Influenced by many programming languages, easier for nonprogrammers.
Dr. Qusai Abuein1 Internet & WWW How to program Chap.(6) JavaScript:Introduction to Scripting.
JavaScript Syntax, how to use it in a HTML document
Introduction to JavaScript CS101 Introduction to Computing.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
 2000 Deitel & Associates, Inc. All rights reserved. Outline 8.1Introduction 8.2A Simple Program: Printing a Line of Text in a Web Page 8.3Another JavaScript.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
Introduction into JavaScript Java 1 JavaScript JavaScript programs run from within an HTML document The statements that make up a program in an HTML.
Java Script About Java Script Document Object Model Incorporating JavaScript Adding JavaScript to HTML Embedding a Javascript External Scripts Javascript.
Chapter 2 Murach's JavaScript and jQuery, C2© 2012, Mike Murach & Associates, Inc.Slide 1.
PHP Syntax You cannot view the PHP source code by selecting "View source" in the browser - you will only see the output from the PHP file, which is plain.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Introduction to JavaScript MIS 3502, Fall 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 9/29/2016.
JavaScript Part 1 Introduction to scripting The ‘alert’ function.
CSS Colors, JavaScript Variables, Conditionals and Basic Methods
CGS 3066: Web Programming and Design Spring 2017
Chapter 6 JavaScript: Introduction to Scripting
JavaScript is a programming language designed for Web pages.
Chapter 13 - JavaScript/JScript: Introduction to Scripting
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
JavaScript.
Chapter 19 JavaScript.
Introduction to JavaScript
JavaScript Introduction
JavaScript an introduction.
DHTML Javascript Internet Technology.
A second look at JavaScript
CSS Colors, JavaScript Variables, Conditionals and Basic Methods
Functions BIS1523 – Lecture 17.
A (gentle???) Introduction to JavaScript
WEB PROGRAMMING JavaScript.
DHTML Javascript Internet Technology.
T. Jumana Abu Shmais – AOU - Riyadh
JavaScript and the DOM MIS 2402 Jeremy Shafer Department of MIS
Programming Control Structures with JavaScript Part 2
Loops and Arrays in JavaScript
NodeJS, Variables, Input/Output (I/O)
JavaScript objects, functions, and events
Introduction to JavaScript
Introduction to JavaScript
JavaScript CS 4640 Programming Languages for Web Applications
Tutorial 10: Programming with javascript
Introduction to JavaScript
JavaScript Basics What is JavaScript?
Introducing JavaScript
JavaScript is a scripting language designed for Web pages by Netscape.
JavaScript: Introduction to Scripting
NodeJS, Variables, Input/Output (I/O)
CIS 136 Building Mobile Apps
Murach's JavaScript and jQuery (3rd Ed.)
Presentation transcript:

An Introduction to JavaScript MIS 2402 Jeremy Shafer Department of MIS Fox School of Business Temple University

Let’s talk about… Chapter 2 What does JavaScript do for us? What were your key take-aways? Confusing items? Talk about languages: JavaScript vs HTML (General purpose vs. Domain-Specific languages)

Agenda Where does the JavaScript go? An introduction to variables and syntax basics An introduction to primitive data types Using existing objects, properties, and methods

A block of JavaScript code Where have we seen this before?

Where does JavaScript code go?

Example of an external JavaScript file We would say here that the src attribute of the script tag provides a relative reference to the external JavaScript file.

Example of embedded JavaScript The <script> </script> tag often appears in the <head> of the HTML document. But really it can go anywhere in the document!

JavaScript in the body of an HTML document Here’s an example… two <script> tags mixed in with HTML

The basic syntax rules for JavaScript JavaScript is actually pretty forgiving when it comes to missing semi-colons. Still, it is best to end each statement with a semi-colon.

Variables

Rules for naming variables A list of reserved words are on page 59 of your textbook.

Valid identifiers in JavaScript These are all valid identifiers. Can you think of some invalid identifier names?

Camel casing versus underscore notation theCat theDog theHouse Versus… the_cat the_dog the_house

Naming recommendations for identifiers

JavaScript code with the comments highlighted Discuss: Comments don’t change the way your code works. So, why comment at all?

The basic syntax rules for comments

JavaScript’s primitive data types Discuss: Can you give me an example of each of these? Can you tell me what these are in your own words?

Examples of number values

Examples of string values

The two Boolean values

How to declare and assign a value to a variable in two statements Notice the use of the var command here. We use var when creating a new variable.

How to declare and assign a value to a variable in one statement

Review of Terms

JavaScript’s arithmetic operators WARNING! This is not a complete list. For a full list of arithmetic operators, you should refer to your textbook.

Example: Code that calculates sales tax

The concatenation operators for strings Concatenation is a very common task!

How to concatenate a string and a number with the + operator So far – we’ve talked about primitive data types, and operators to manipulate them. As we consider how to make JavaScript interact with browser, and an HTML document inside the browser, we need to start thinking about objects.

The window object JavaScript allows us to refer to the browser environment using something called the window object. Similarly, we can manipulate the current HTML document with the document object. In any programming language, objects have properties and methods. Methods represent things that the object can do (verbs) and properties represent values that the object has (nouns)

Common methods of the window object

A statement that calls the prompt() method with the object name omitted

One property of the window object

Two methods of the window object

Examples that use the parseInt() and parseFloat() methods

The same examples with the parse methods embedded in the alert() method

Two methods of the document object

Examples of the write() and writeln() methods

The output in a browser

Terms related to objects