JavaScript - PowerPoint PPT Presentation

1 / 7
About This Presentation
Title:

JavaScript

Description:

You do NOT have to specify the datatype of a variable when you ... 'I like the movie 'Top Gun 'with Tom Cruise' 'I like the movie Top Gun' with Tom Cruise' ... – PowerPoint PPT presentation

Number of Views:36
Avg rating:3.0/5.0
Slides: 8
Provided by: informat1027
Category:
Tags: javascript | cruise | tom

less

Transcript and Presenter's Notes

Title: JavaScript


1
JavaScript
  • Variable Names Literals

2
JavaScript Datatypes
  • Numbers (integer and real)
  • Ex. 42, 3.14159
  • Boolean values
  • Ex. True or False
  • Strings
  • Ex. MFHS, Computer Science
  • Null
  • Ex. null

3
DataType Conversion
  • You do NOT have to specify the datatype of a
    variable when you declare it. Datatypes are
    automatically converted as needed during the
    course of script execution.
  • Defining a variable
  • var answer 50
  • Reassigning the same variable
  • answer Yes

Holding a number
Holding a string
4
Variable Names
  • The "Golden Rules" of Variables
  • Variable names may contain any combination of
    letters, numbers, and the underscore ('_')
    character, but may only begin with a letter or
    underscore.
  • A variable's name should describe what it does.
  • All variables must be declared using the var
    command.
  • Examples
  • First_Name
  • num5
  • _super

5
Scope of a Variable
  • Global
  • You can use the variable anywhere in the
    application
  • Ex. var total 0
  • Local
  • You can use the variable within the current
    function
  • Ex. var total 0

6
Literals
  • String Literals
  • Enclosed in either single or double quotes
  • blah
  • blah
  • 1234
  • Null
  • Used to represent variables which have not been
    initialized
  • Integers
  • Can be expressed in decimal(base10),
    hexadecimal(base16), or octal(base8) format.
  • Floating Point Literals
  • Decimal point 3.1415
  • Exponent 2.5E3
  • Signs -3.5e-2
  • Boolean
  • true or false

7
Special Characters
  • \b backspace
  • \f form feed
  • \n new line character
  • \r carriage return
  • \t tab character
  • Quote inside of quote
  • I like the movie \Top Gun \with Tom Cruise
  • I like the movie Top Gun with Tom Cruise
Write a Comment
User Comments (0)
About PowerShow.com