1 / 19

Introduction to JavaScript

Introduction to JavaScript. CSc 2320 Fall 2013. Disclaimer: All words, pictures are adopted from “Simple JavaScript”by Kevin Yank and Cameron Adams and also from W3schools. Edited by Guoliang Liu, Only for Course CSc2320 at GSU CS Department. Resources. Simple Javascript

jean
Download Presentation

Introduction to JavaScript

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to JavaScript CSc 2320 Fall 2013 Disclaimer: All words, pictures are adopted from “Simple JavaScript”by Kevin Yank and Cameron Adams and also from W3schools. Edited by Guoliang Liu, Only for Course CSc2320 at GSU CS Department

  2. Resources • Simple Javascript • By kevin Yank and Cameron Adams • W3Schools. • http://www.w3schools.com/js/default.asp

  3. In this chapter • Introduction to JavaScript • Three Layers of Web • Programming with JavaScript • Running a JavaScript Program • Statements • Comments • Variable • Date types • Operations

  4. Introduction to JavaScript • JavaScript is a Scripting Language • Lightweight programming language • Programming code embedded in HTML • Can be executed by all modern web browsers • Java and JavaScript • Nothing like each other but some syntax. • Standardized JavaScript: • ECMAScript (newest 5.1)

  5. Three Layers of Web • The way to create pages in the way back. • HTML, CSS, JavaScript all in one file.

  6. Separation of Three Layers • HTML: Content • CSS: Presentation • JavaScript: Behavior

  7. The third layer: Behavior • JavaScript: Writing Into HTML Output • JavaScript: Reacting to Events • JavaScript: Changing HTML Element • JavaScript: Changing HTML Content • JavaScript: Changing HTML Images • JavaScript: Changing HTML Styles • JavaScript: Validate Input • Check out the examples here: • http://www.w3schools.com/js/js_intro.asp

  8. Programming with JavaScript • Running a JavaScript Program • Two ways to insert JavaScript code • Internal: • External:

  9. JavaScript Statements • In JavaScript each statement has to be separated by a new line or a semicolon. So, two statements could be written like this: • Or • Or both:

  10. Comments • Exactly the same with Java • Single line: • Multiple lines:

  11. Variables: Store the data • Declare a variable: • varcolor; • Declare and initialize: • var color; • color = “blue”; • Or var color = “blue”; • assignment operator (=).

  12. Data Types for a variable • Numbers • integer or int. E.g., 3, 5, 100 • Floating point number or float. E.g., 3.1415 • varnum = 5; • var decimal = 10.2; • Strings • A series of characters coverd by ‘’ or “” • var single = 'Just single quotes'; • var double = "Just double quotes";

  13. Data Types for a variable • Booleans • True or false; • varlying = true; • var truthful = false; • Arrays • good ways to store individual pieces of data

  14. Data Types for a variable • Arrays (cont.) • More examples:

  15. Data Types for a variable • Associative arrays: • Key-value in the array

  16. Operations for variables • JavaScript Arithmetic Operators • Given y = 5;

  17. Operations for variables • JavaScript Assignment Operators

  18. Operations for variables • The + Operator Used on Strings

  19. Homework • Write a simple JavaScript to pop up an alert. • No need to submit.

More Related