JavaScript Variables. Definition A variable is a "container" for information you want to store. A variable's value can change during the script.

Slides:



Advertisements
Similar presentations
PHP functions What are Functions? A function structure:
Advertisements

Local Variables and Scope Benjamin Fein. Variable Scope A variable’s scope consists of all code blocks in which it is visible. A variable is considered.
Javascript Essentials How do I write it??  Start Homesite  Between the start and end BODY tags type: 
Function with Output Parameters 4 We have seen that functions can return a single value or no value (void return type) 4 It is quite often useful to be.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic JavaScript: Functions Part I.
110-D1 Variables, Constants and Calculations(1) Chapter 3: we are familiar with VB IDE (building a form…) to make our applications more powerful, we need.
Identifiers and Assignment Statements. Data structures In any programming language you need to refer to data The simplest way is with the actual data.
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:
Using Data Active Server Pages Objectives In this chapter, you will: Learn about variables and constants Explore application and session variables Learn.
Adding JavaScript (<script tag>)
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:
1 VBA – podstawowe reguły języka Opracowanie Janusz Górczyński wg Microsoft Help.
Variables, Assignment & Math Storing and naming data.
CISC474 - JavaScript 03/02/2011. Some Background… Great JavaScript Guides: –
Tutorial 2 Variables and Objects. Working with Variables and Objects Variables (or identifiers) –Values stored in computer memory locations –Value can.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
CNIT 133 Interactive Web Pags – JavaScript and AJAX Advanced topic - variable.
Copyright 1999 by Larry Fuhrer. Pascal Programming Getting Started...
VARIABLES & CONSTANTS. Objective By the end of the lesson students should be able to:  Define a constant  Define a variable  Understand the rules for.
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Variables, Functions and Events (there is an audio component to this eLesson) © Dr.
JavaScript Syntax and Semantics. Slide 2 Lecture Overview Core JavaScript Syntax (I will not review every nuance of the language)
BASICS CONCEPTS OF ‘C’.  C Character Set C Character Set  Tokens in C Tokens in C  Constants Constants  Variables Variables  Global Variables Global.
CS346 Javascript -3 Module 3 JavaScript Variables.
JavaScript Syntax, how to use it in a HTML document
_______________________________________________________________________________________________________________ PHP Bible, 2 nd Edition1  Wiley and the.
CHAPTER # 2 Part 2 PROGRAMS AND DATA 1 st semster King Saud University College of Applied studies and Community Service CSC1101 By: Asma Alosaimi.
C++ Basics. Compilation What does compilation do? g++ hello.cpp g++ -o hello.cpp hello.
© 2000 – All Rights Reserved - Page 1 Introduction to JavaScript Programming Part One.
Variables and Assignment CSIS 1595: Fundamentals of Programming and Problem Solving 1.
JavaScript Assignment Statements Expressions Global Functions CST 200 JavaScript.
Data And Variables Chapter Names vs. Values Michael Jordan name (the letter sequence used to refer to something) value (the thing itself)
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.
PHP Variables.  Variables are "containers" for storing information. How to Declare PHP Variables  In PHP, a variable starts with the $ sign, followed.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP Basics.
Chapter 3 Introduction to PHP. Incorporating PHP Within HTML By default, PHP documents end with the extension.php files ending with.htm or.html to also.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
C BASICS QUIZ (DATA TYPES & OPERATORS). C language has been developed by (1) Ken Thompson (2) Dennis Ritchie (3) Peter Norton (4) Martin Richards.
Chapter 2. Variable and Data type
JavaScript and Ajax (JavaScript Basic) Week 2 Web site:
PHP Reusing Code and Writing Functions 1. Function = a self-contained module of code that: Declares a calling interface – prototype! Performs some task.
Department of Electronic & Electrical Engineering Statements Blocks{} Semicolons ; Variables Names keywords Scope.
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,
JavaScript Modularity. Goals By the end of this lecture, you should … Understand why programmers use modularity. Understand how to create a function in.
Arithmetic Operations (L05) * Arithmetic Operations * Variables * Declaration Statement * Software Development Procedure Problem Solving Using C Dr. Ming.
Modern JavaScript Develop And Design Instructor’s Notes Chapter 4 – Simple Variable Types Modern JavaScript Design And Develop Copyright © 2012 by Larry.
JavaScript Variables Like other programming languages, JavaScript variables are a container that contains a value - a value that can be changed/fixed.
CS346 Javascript-41 Module 4 JavaScript Functions.
JavaScript Tutorial First lecture 19/2/2016. Javascript is a dynamic computer programming language. It is lightweight and most commonly used as a part.
Introduction to Python Lesson 2a Print and Types.
Java Script Introduction. Java Script Introduction.
JAVA Script : Functions Ashima Wadhwa
CNIT 133 Interactive Web Pags – JavaScript and AJAX
JavaScript Syntax and Semantics
trigraph ??= is for # ??( is for [ ??< is for { ??! is for |
JavaScript.
Chapter 4 Procedural Methods.
Microsoft Visual Basic 2005 BASICS
FIGURE 4-10 Function Return Statements
Unit-1 Introduction to Java
FIGURE 4-10 Function Return Statements
Variables Kevin Harville.
For this assignment, copy and past the XHTML to a notepad file with the .html extension. Then add the code I ask for to complete the problems.
The Data Element.
Tutorial 10: Programming with javascript
The Data Element.
FIGURE 4-10 Function Return Statements
Understanding Variables
C Programming Lecture-3 Keywords, Datatypes, Constants & Variables
Scope Rules.
Presentation transcript:

JavaScript Variables

Definition A variable is a "container" for information you want to store. A variable's value can change during the script.

Rules for JavaScript Variables Can contain any letter of the alphabet, digits 0-9, and the underscore character. No spaces No punctuation characters (eg comma, full stop, etc) The first character of a variable name cannot be a digit. JavaScript variables' names are case-sensitive. For example firstName and FirstName are two different variables.

Declare a Variable you can create a variable with the var statement: var strname = some value You can also create a variable without the var statement: strname = some value

Assign a Value to a Variable you can assign a value to a variable like this: var strname = "Hege" Or like this: strname = "Hege" The variable name is on the left side of the expression and the value you want to assign to the variable is on the right. Now the variable "strname" has the value "Hege".

JavaScript Variable Scope: The scope of a variable is the region of your program in which it is defined. JavaScript variable will have only two scopes. Global Variables: A global variable has global scope which means it is defined everywhere in your JavaScript code. Local Variables: A local variable will be visible only within a function where it is defined. Function parameters are always local to that function.

Example <!-- var myVar = "global"; // Declare a global variable function checkscope( ) { var myVar = "local"; // Declare a local variable document.write(myVar); } //-->

The End …Thank you…