CS346 Javascript -3 Module 3 JavaScript Variables.

Slides:



Advertisements
Similar presentations
/ 251 Internet Applications Ahmed M. Zeki Sem – / Chapter 8.
Advertisements

JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
CSci 1130 Intro to Programming in Java
The Web Warrior Guide to Web Design Technologies
Constants and Data Types Constants Data Types Reading for this class: L&L,
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.
JavaScript, Fourth Edition
Chapter 2: Introduction to C++.
JavaScript, Third Edition
Variable & Constants. A variable is a name given to a storage area that our programs can manipulate. Each variable in C has a specific type, which determines.
WEB DESIGN AND PROGRAMMING Introduction to Javascript.
The Data Element. 2 Data type: A description of the set of values and the basic set of operations that can be applied to values of the type. Strong typing:
2440: 211 Interactive Web Programming Expressions & Operators.
Tutorial 2 Variables and Objects. Working with Variables and Objects Variables (or identifiers) –Values stored in computer memory locations –Value can.
Chapter 3: Data Types and Operators JavaScript - Introductory.
1 JavaScript in Context. Server-Side Programming.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
C Derived Languages C is the base upon which many build C++ conventions also influence others *SmallTalk is where most OOP comes Java and Javascript have.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Chapter 2 Elementary Programming
Chapter 2: Java Fundamentals
The Grammar of JavaScript.  Each line of a script is a statement  An instruction that JavaScript can evaluate (make sense of)  Ends with a semicolon;
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Variables, Functions and Events (there is an audio component to this eLesson) © Dr.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
BASICS CONCEPTS OF ‘C’.  C Character Set C Character Set  Tokens in C Tokens in C  Constants Constants  Variables Variables  Global Variables Global.
CHAPTER 4 GC 101 Data types. DATA TYPES  For all data, assign a name (identifier) and a data type  Data type tells compiler:  How much memory to allocate.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 2: Introduction to C++
Introduction to Programming JScript Six Scripting functions Discuss functions Password Example.
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
Tharith Sriv.  JavaScript is a simple programming language that can be written directly into HTML documents to allow for increased interactivity with.
VARIABLES AND DATA TYPES Chapter2:part1 1. Objectives: By the end of this section you should: Understand what the variables are and why they are used.
Variables and Data Types Data (information we're going to store) – Numbers – Text – Dates What types of data can JavaScript process? How do we store it?
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.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Python Let’s get started!.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Part:2.  Keywords are words with special meaning in JavaScript  Keyword var ◦ Used to declare the names of variables ◦ A variable is a location in the.
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP Basics.
 Variables can store data of different types, and different data types can do different things.  PHP supports the following data types:  String  Integer.
Basic Scripting & Variables Yasar Hussain Malik - NISTE.
JavaScript and Ajax (JavaScript Data Types) Week 2 Web site:
Session 2: PHP Language Basics iNET Academy Open Source Web Development.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Introduction to C++
Modern JavaScript Develop And Design Instructor’s Notes Chapter 4 – Simple Variable Types Modern JavaScript Design And Develop Copyright © 2012 by Larry.
REEM ALMOTIRI Information Technology Department Majmaah University.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
JavaScript Variables. Definition A variable is a "container" for information you want to store. A variable's value can change during the script.
>> Introduction to JavaScript
Chapter 6 JavaScript: Introduction to Scripting
Scope, Objects, Strings, Numbers
Introduction to Scripting
14 A Brief Look at JavaScript and jQuery.
Chapter 4 Procedural Methods.
2.1 Parts of a C++ Program.
WEB PROGRAMMING JavaScript.
PHP.
JavaScript What is JavaScript? What can JavaScript do?
Variables Kevin Harville.
Chapter 7 Procedural Methods.
JavaScript What is JavaScript? What can JavaScript do?
Chapter 2: Introduction to C++.
Tutorial 10: Programming with javascript
JavaScript: Introduction to Scripting
Variables Here we go.
Variables and Constants
Presentation transcript:

CS346 Javascript -3 Module 3 JavaScript Variables

CS346 Javascript -3 Variables  Variable — value stored in computer memory location Represents a value that can be changed anytime Saves time in writing and updating scripts Makes the purpose of the code clearer  Use the reserved keyword var to create variables  Reserved words, or keywords, are part of the JavaScript syntax  Cannot be used for variable names

CS346 Javascript -3 Variables  Variables must begin with a letter, $, or _ Cannot contain any spaces  Variables, like other JavaScript code, are case-sensitive  You can declare multiple variables in a statement by separating them with commas var first=1, second=“two”, third=“three”;

CS346 Javascript -3 Variables  Conventions Use a lowercase letter for the first letter of first word and uppercase for subsequent words myVariable Use _ to separate individual words my_variable

CS346 Javascript -3 Variable Scope  Variable scope can be either global or local  A global variable is declared outside of a function Available to all parts of the program  A local variable is declared inside a function and is only available within the function Arguments within the parentheses of a function are considered local variables

CS346 Javascript -3 Data Types  String eval( ) myValue = eval(“1+2”); parseInt( ) or parseFloat( ) Start = parseInt(document.form.start.value); Number( ) Start = Number(document.form.start.value); String( ) var num = 10; var numStr = String(num); isNaN( ) Num = isNaN(document.form.start.value);  Integer 8 1,  Floating Point e13  Boolean True False  Null

CS346 Javascript -3 Special Characters  Escaping — Displaying special characters Use the backslash ‘\’  HTML Tags Enclosed in Quotes  Escape Sequences \n = New Line \r = Carriage Return \t = Tab \’ = Single Quote \” = Double Quote \\ = Backslash

CS346 Javascript -3 Example  3-1variable.htm 3-1variable.htm