Download presentation
Presentation is loading. Please wait.
Published byΆλκηστις Αργυριάδης Modified over 5 years ago
1
JavaScript What is JavaScript? What can JavaScript do?
Three ways to invoke JavaScript Important JavaScript Facts Data types and values Creating Variable Syntax for JavaScript Statements JavaScript Examples
2
What is JavaScript? JavaScript is a simplest programming language
JavaScript is not Java Syntax similar but variable has no data type. JavaScript controls browsers behavior Cannot draw Graphics, & do multithreading
3
What can JavaScript do? JavaScript can interact by…
Putting dynamic text into HTML page Reacting to Events Validate data
4
Three ways to invoke JavaScript
Inline code found between <script> and </script> tag. Inline code is invoked or executed when the browser gets up to the line of code From the Event Handler. In response to a specific things that the user does As a timed event, you can set up a timer that goes off regularly at a predetermined interval and each time a specific code gets executed.
5
Important JavaScript Facts
JavaScript is case sensitive Inside a double quote, you must use a single quote JavaScript has whitespace; it ignores extra spaces Every statement must end with a semicolon
6
Data Types and Values Numbers-integer, hexadecimal, floating point
Strings- number or letters enclosed between quotation Escape sequence (\n, \t, \”) Boolean Values is either true or false
7
Data Types and Values Function is block of statement which is defined once and can be executed many times Function can have passed argument or parameter Functions can return value or not return value Array object is used to store a list of values
8
Creating Variable Variable is a name associated with the data value or text; it stores the data. Assignment Statement var variablename = ; Semantics (meaning) Evaluate the expression Copy the result into the variable on the left-hand side of the equal sign value/text/Expression
9
Syntax for JavaScript Statements
objectname.properties = “ ”; Examples: Assign background color for the page document.bgColor = “ ”; Assign information on the status bar window.status = “ ”; Assign a page to load in the window window.location = “ ”;
10
Syntax for JavaScript Statements
variablename = objectname.properties; Examples: Get background color for the page var backgroundC = document.bgColor; Get information on the status bar var current status = window.status; Get current page address var page = window.location;
11
Syntax for JavaScript Statements
objectname.methodname(); variablename=objectname.methodname(); Examples: window.alert(); document.write() var data = window.prompt();
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.