JavaScript Jordan Clark, Jamie Kapilivsky, Taylor Monk, Jessica Torres.

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

Introducing JavaScript
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Javascript Introduction Norman White Material is from w3schools.com Go there to run examples interactively.
HTML Forms JavaScript Introduction / Overview Lab Homework #1 CS 183 4/8/2010.
CS 898N – Advanced World Wide Web Technologies Lecture 14: JavaScript Chin-Chih Chang
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
Tutorial 10 Programming with JavaScript
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers.
JavaScript Switch Statement. Switch JavaScript Switch Statement If you have a lot of conditions, you can use a switch statement instead of an if…elseif…
Introduction to scripting
آموزش طراحی وب سایت جلسه دهم – جاوا اسکریپت 1 تدریس طراحی وب برای اطلاعات بیشتر تماس بگیرید تاو شماره تماس: پست الکترونیک :
Arrays and Control Structures CST 200 – JavaScript 2 –
Adding JavaScript (<script tag>)
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
Programming with JavaScript (Chapter 10). XP Various things Midterm grades: Friday Winter Career Fair – Thursday, April 28, 2011 (11 am to 3 pm). – MAC.
Week 9 PHP Cookies and Session Introduction to JavaScript.
CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad GM-IT CIIT Islamabad CIIT Virtual Campus, CIIT COMSATS Institute.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
1 JavaScript 1. 2 Java vs. JavaScript Java –Is a high level programming language –Is platform independent –Runs on a standardized virtual machine.
CIS 375—Web App Dev II JavaScript II.
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 Session 2: What is JavaScript?
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.
Introduction to JavaScript Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan. 1.
PHP Conditional Statements Conditional statements in PHP are used to perform different actions based on different conditions. Conditional Statements Very.
Chapter 2 Functions and Control Structures PHP Programming with MySQL 2 nd Edition.
JavaScript Syntax and Semantics. Slide 2 Lecture Overview Core JavaScript Syntax (I will not review every nuance of the language)
LOGO Conditional Statements & Loops in JavaScript CHAPTER 10 Eastern Mediterranean University School of Computing and Technology Department of Information.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
JavaScript Syntax, how to use it in a HTML document
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
JavaScript. JavaScript is the programming language of HTML and the Web. Easy to learn One of the 3 languages of all developers MUST learn: 1. HTML to.
COMP403 Web Design JAVA SCRİPTS Tolgay KARANFİLLER.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
1 JavaScript in Context. Server-Side Programming.
COP 3813 Intro to Internet Computing Prof. Roy Levow Lecture 4 JavaScript.
Pertemuan 5 IT133 Pengembangan Web JavaScript. What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting.
Chapter 2 Murach's JavaScript and jQuery, C2© 2012, Mike Murach & Associates, Inc.Slide 1.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Chapter 5: Intro to Scripting CIS 275—Web Application Development for Business I.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
Introduction to Javascript. What is javascript?  The most popular web scripting language in the world  Used to produce rich thin client web applications.
JavaScript JavaScript ( Condition and Loops ). Conditional Statements If Statement If...else Statement if (condition) { code to be executed if condition.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
Learning Javascript From Mr Saem
JavaScript and AJAX 2nd Edition Tutorial 1 Programming with JavaScript.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
JavaScript Tutorial. What is JavaScript JavaScript is the programming language of HTML and the Web Programming makes computers do what you want them to.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
>> Introduction to JavaScript
Web Systems & Technologies
My First Web Page document.write("" + Date() + ""); To insert.
JavaScript Syntax and Semantics
JavaScript Netcentric.
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
Chapter 19 JavaScript.
Introduction to Client-Side Scripting and JavaScript
PHP.
T. Jumana Abu Shmais – AOU - Riyadh
Tutorial 10: Programming with javascript
Presentation transcript:

JavaScript Jordan Clark, Jamie Kapilivsky, Taylor Monk, Jessica Torres

Background Who: Brendan Eich What: A lightweight, interpreted language that appeals to non-professional programmers When: 1995 Where: Netscape Why: Netscape was competing with Microsoft

Background Today: JavaScript is a widely-used programming language used for both web pages as well as non-web- related things such as PDFs, desktop widgets, etc.

Syntax – Declaring Variables Examples: var x=5; var y=6; var z=x+y; You declare JavaScript variables using the var keyword JS variables can hold values (x=5), expressions (z=x+y), or text values (name=“John Doe”)

Syntax – Declaring Variables Variable names: Must begin with a letter Can also begin with $ and _ Are case sensitive (Y and y are different variables) Can be short (like x and y) or more descriptive (age, sum, totalvolume)

Syntax – If Statements “if” is written in lowercase letters Using uppercase letters (“IF”) will generate a JS error Example: if (time<20) { x=“Good day”; }

Syntax – If Statements Example: if (time<20) { x="Good day"; } Else { x="Good evening"; }

Syntax – If Statements Example: if (time<10) { x="Good morning"; } else if (time<20) { x="Good day"; } else { x="Good evening"; }

Syntax – Data Types JS is weakly typed. AKA the same variable can be used as different types: var x // Now x is undefined var x = 5; // Now x is a Number var x = "John"; // Now x is a String When you declare a new variable, use the “new” keyword: var carname=new String; var x= new Number; var y= new Boolean;

Syntax – String Example: var carname="Volvo XC60"; var carname='Volvo XC60'; You can use quotes inside a string, as long as they don't match the quotes surrounding the string var answer=”He is called ‘Johnny’”;

Syntax – Numbers Example: var x1=34.00; //Written with decimals var x2=34; //Written without decimals Extra large or extra small numbers can be written with scientific (exponential) notation var y=123e5; //

Syntax – Boolean and Date & Time Boolean: var x=true var y=false Date and time:

Syntax – Comments Example: // Write to a heading: document.getElementById("myH1").innerHTML="Welcome to my Homepage"; Example: /* The code below will write to a heading and to a paragraph, and will represent the start of my homepage: */ document.getElementById("myH1").innerHTML="Welcome to my Homepage"; document.getElementById("myP").innerHTML="This is my first paragraph.";

Syntax – Output You can manipulate HTML elements from JavaScript using the “document.getElementById(id)” method: Title document.getElementById("hello").innerHTML="Hello World"; You may also write directly to the HTML document using “document.write()”: document.write(" Hello World ");

Syntax – For/Next Loops Statement 1 sets the variable before the loop starts Statement 2 defines the condition for the loop to run Statement 3 increases the value each time the code has been executed General form: for (statement 1; statement 2; statement 3) { the code block to be executed }

Syntax – For/Next Loops Example: for (var i=0; i<5; i++) { x=x + "The number is " + i + " "; } This loop will start at zero and will increment by one when i is less than 5. In this case, the resulting output will be: The number is 0 The number is 1 The number is 2 The number is 3 The number is 4 *Note: i ++ is the same as i = i + 1

Syntax – Do/While Loops General Form: do { code to be executed } while (condition);

Syntax – Do/While Loops Example: ar x="",i=0; do { x=x + "The number is " + i + " "; i++; } while (i<5); This loop will start with i = 0 and increment by 1 while i is less than 5. The resulting output is: The number is 0 The number is 1 The number is 2 The number is 3 The number is 4

Syntax – Select Case/Switch Example: var day=new Date().getDay(); switch (day) { case 0: x="Today it's Sunday"; break; case 1: x="Today it's Monday"; break; case 2: x="Today it's Tuesday"; break; case 3: x="Today it's Wednesday"; break; case 4: x="Today it's Thursday"; break; case 5: x="Today it's Friday"; break; case 6: x="Today it's Saturday"; break; } The result of x will be: Today it's Sunday

Syntax – Select Case/Switch Use the “default” keyword to specify what to do if there is no match Example: var day=new Date().getDay(); switch (day) { case 6: x="Today it's Saturday"; break; case 0: x="Today it's Sunday"; break; default: x="Looking forward to the Weekend"; }

Syntax – JS Arithmetic Operators

Syntax – JS Assignment Operators

Helpful Sources Websites: Books: JavaScript: The Good Parts by Douglas Crockford (May 2008) JavaScript & jQuery: The Missing Manual By: David Sawyer McFarlan JavaScript Step by Step By: Steve Suehring Beginning JavaScript, 3rd Edition By: Paul Wilton & Jeremy McPeak