Adapted from  2004 Prentice Hall, Inc. All rights reserved. 5 th and 4 th ed: Chapters 6,7,8 SY306 Web and Databases for Cyber Operations SlideSet #6:

Slides:



Advertisements
Similar presentations
Types of selection structures
Advertisements

CS107 Introduction to Computer Science Lecture 3, 4 An Introduction to Algorithms: Loops.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
Page 1 of 26 Javascript/Jscript Ch 7,8,9,10 Vadim Parizher Computer Science Department California State University, Northridge Spring 2003 Slides from.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic JavaScript: Introduction to Scripting.
Java review and more. Class Header  Public class Welcome  Case sensitive  Body of the class must be enclosed by braces.
 2001 Deitel & Associates, Inc. All rights reserved. 1 Outline 14.1Introduction 14.2Algorithms 14.3Pseudocode 14.4Control Structures 14.5The if Selection.
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.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Mathematical Operators  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course. Introduction to Computers and Programming in.
Relational Operators Control structures Decisions using “if” statements  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course.
1 JavaScript/Jscript: Arrays. 2 Introduction Arrays –Data structures consisting of related data items (collections of data items) JavaScript arrays are.
Introduction to JavaScript for Python Programmers
Introduction to scripting
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 8 - JavaScript: Control Structures I Outline 8.1 Introduction 8.2 Algorithms 8.3 Pseudocode 8.4.
JavaScript: Control Structures September 27, 2005 Slides modified from Internet & World Wide Web: How to Program (3rd) edition. By Deitel, Deitel,
 2004 Prentice Hall, Inc. All rights reserved. Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
WEB DESIGN AND PROGRAMMING Introduction to Javascript.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 10 - JavaScript: Functions Outline 10.1 Introduction 10.2 Program Modules in JavaScript 10.3.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 10 - JavaScript: Functions Outline 10.1 Introduction 10.2 Program Modules in JavaScript 10.3.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Ch 6: JavaScript Introduction to scripting part 2.
 2000 Prentice Hall, Inc. All rights reserved. 1 Chapter 2 - Introduction to Java Applications Outline 2.1Introduction 2.2A Simple Program: Printing a.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 23 - Wireless Internet and m- Business Outline 23.1 Introduction 23.2 M-Business 23.3 Identifying.
1 COMP 241: Object-Oriented Programming with Java Fall 2004 Lecture 1 September 27, 2004 Serdar Taşıran.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 17 - WMLScript: Control Structures I Outline 17.1 Introduction 17.2 Algorithms 17.3 Pseudocode.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 8 - JavaScript: Control Structures I Outline 8.1 Introduction 8.2 Algorithms 8.3 Pseudocode 8.4.
Dr. Qusai Abuein1 Internet & WWW How to program Chap.(6) JavaScript:Introduction to Scripting.
Input & Output Functions JavaScript is special from other languages because it can accept input and produce output on the basis of that input in the same.
1 JavaScript: Control Structures. 2 Control Structures Flowcharting JavaScript’s sequence structure.
Introduction to Programming JScript Six Scripting functions Discuss functions Password Example.
 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.
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 10 - JavaScript/JScript: Control Structures II Outline 10.1Introduction 10.2Essentials of.
1 Chapter 3 – JavaScript Outline Introduction Flowcharts Control Structures if Selection Structure if/else Selection Structure while Repetition Structure.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
ECA 225 Applied Interactive Programming ECA 225 Applied Online Programming control structures, events, objects.
JavaScript 1 COE 201- Computer Proficiency. Introduction JavaScript scripting language ▫Originally created by Netscape ▫Facilitates disciplined approach.
Adapted from  2012 Prentice Hall, Inc. All rights reserved. 5 th ed: Chapter 2 and th ed: 4.11 SY306 Web and Databases for Cyber Operations.
 2003 Prentice Hall, Inc. All rights reserved. Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing a Line of Text in a Web Page 7.3 Another JavaScript.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
(Some from Chapter 11.9 – “Web” 4 th edition and
Chapter 4 Java Script - Part1. 2 Outlines Introduction to Java Script Variables, Operators and Functions Conditional statements JavaScript Objects Forms.
5 th and 4 th ed: Chapters 9, 10, 11 SY306 Web and Databases for Cyber Operations SlideSet #7: JavaScript Functions and Arrays.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 9 - JavaScript: Control Structures II Outline 9.1 Introduction 9.2 Essentials of Counter-Controlled.
Javascript| SCK3633 Web Programming | Jumail, FSKSM, UTM, 2006 | Last Updated January 2006 Slide 1 Javascript Lecture 4 Lecture 4: Javascript| SCK3633.
1 JavaScript/Jscript 2 Control Structures I. 2 Introduction Before programming a script have a –Thorough understanding of problem –Carefully planned approach.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
INTERNET APPLICATIONS CPIT405 JavaScript Instructor: Rasha AlOmari
WEB SYSTEMS & TECHNOLOGY. Java Script  JavaScript created by Netscape  It is also client side programming  It can be use for client side checks.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 11 - JavaScript: Arrays Outline 11.1 Introduction 11.2 Arrays 11.3 Declaring and Allocating Arrays.
JavaScript: Control Structures I Outline 1 Introduction 2 Algorithms 3 Pseudocode 4 Control Structures 5 if Selection Structure 6 if/else Selection Structure.
 2001 Prentice Hall, Inc. All rights reserved. Outline 1 JavaScript.
JavaScript: Control Structures I
Chapter 13 - JavaScript/JScript: Introduction to Scripting
WEB APPLICATION PROGRAMMING
Chapter 7 - JavaScript: Introduction to Scripting
Chapter 8 - JavaScript: Control Structures I
JavaScript: Introduction to Scripting
WEB PROGRAMMING JavaScript.
3. Decision Structures Rocky K. C. Chang 19 September 2018
Chapter 7 - JavaScript: Introduction to Scripting
JavaScript: Introduction to Scripting
Chapter 7 - JavaScript: Introduction to Scripting
Chapter 7 - JavaScript: Introduction to Scripting
Chapter 8 - JavaScript: Control Structures I
Chapter 7 - JavaScript: Introduction to Scripting
Presentation transcript:

Adapted from  2004 Prentice Hall, Inc. All rights reserved. 5 th and 4 th ed: Chapters 6,7,8 SY306 Web and Databases for Cyber Operations SlideSet #6: Intro to JavaScript

Adapted from  2004 Prentice Hall, Inc. All rights reserved. JavaScript Intro – Outline What is it good for? What does it look like? JavaScript vs Python? Example Usage

Adapted from  2004 Prentice Hall, Inc. All rights reserved. What’s JavaScript good for? Client-side computation? Server-side computation?

welcome3.html 1 of 1 Printing Multiple Lines <!-- document.writeln( " Welcome to JavaScript" + " Programming! " ); // -->

Printing Multiple Lines in a Dialog Box <!— window.alert( "Welcome to\nJavaScript\nProgramming!" ); // --> Click Refresh (or Reload) to run this script again. welcome4.html 1 of 1

Adapted from  2004 Prentice Hall, Inc. All rights reserved. Python vs. JavaScript Object-oriented? Add methods/properties to objects at run-time? Variable typing? If statements, loops, etc?

Adapted from  2004 Prentice Hall, Inc. All rights reserved. Addition / Strings Example – Part 1

addition.html An Addition Program <!-- var firstNumber, secondNumber, number1, number2, sum; // read in first number from user as a string firstNumber = window.prompt( "Enter first integer", "0" ); // read in second number from user as a string secondNumber = window.prompt( "Enter second integer", "0" ); // convert numbers from strings to integers number1 = parseInt( firstNumber ); number2 = parseInt( secondNumber ); // add the numbers sum = number1 + number2; // display the results document.writeln( " The sum is " + sum + " " ); // --> Click Refresh (or Reload) to run the script again Addition / Strings Example – Part 2

Adapted from  2004 Prentice Hall, Inc. All rights reserved. Operators and Precedence

Adapted from  2004 Prentice Hall, Inc. All rights reserved. Exercise #1 -- What’s the output? var x, y, z; x = 7; y = 9; z = "abc"; window.alert(x+y+z); window.alert(z+y+x); if (x) window.alert("x true"); x = "seven"; window.alert(x+y+z);

Adapted from  2004 Prentice Hall, Inc. All rights reserved. Objects and Control Flow – Part 1

Using Relational Operators <!-- var now = new Date(); // current date and time hour = now.getHours(); // current hour (0-23) // determine whether it is morning if ( hour < 12 ) document.write( " Good Morning, " ); // determine whether the time is PM if ( hour >= 12 ) { // convert to a 12 hour clock hour = hour - 12; // determine whether it is before 6 PM if ( hour < 6 ) document.write( " Good Afternoon, " ); // determine whether it is after 6 PM if ( hour >= 6 ) document.write( " Good Evening, " ); } document.writeln( "the date is: " + now + “ ”); // --> Click Refresh (or Reload) to run this script again. Objects and Control Flow – Part 2

Adapted from  2004 Prentice Hall, Inc. All rights reserved. Exercise #2 -- What’s the output? var a, b, c; a = 1; b = 2; c = 3; d = a + b * c; window.alert(" Begin "); if (d < 20) window.alert("d is okay: "+d); else window.alert("d is too high!:"+ d); d = d - 3; document.writeln(" Done. Final d = "+d+" ");

Adapted from  2004 Prentice Hall, Inc. All rights reserved. Exercise #3 Write a JavaScript snippet to read in a number from the user and output its absolute value.

Adapted from  2004 Prentice Hall, Inc. All rights reserved. Strings Empty string: Subscripting: x = “hard”; x[0], x[1], ….length character-to-ASCII-number: string.charCodeAt(index) ASCII-number-to-character: String.fromCharCode(number).substr

Adapted from  2004 Prentice Hall, Inc. All rights reserved. Exercise #4 Look at this: /* Return an integer no larger than ‘max’ */ var max = 25; var value; do { value = window.prompt( "Please enter an integer no larger than "+max); } while (value > max); When does this work and why? When does it fail and how to fix?

Adapted from  2004 Prentice Hall, Inc. All rights reserved. Exercise #5 Write a JavaScript snippet to read in three numbers x, y, z and output them in sorted order.