Presentation is loading. Please wait.

Presentation is loading. Please wait.

JavaScript Create Array object

Similar presentations


Presentation on theme: "JavaScript Create Array object"— Presentation transcript:

1 JavaScript Create Array object
Introduce If statement, comparison operator, logical operator Picture changes from clicking on the channel button Using setInterval() for image to change on it own

2 Create Array object Array is another means to store value
Array stores list of values Each value is an element of the Array and has an associated index Syntax to create an Array var array_name = new Array(size); Example var shopping_list = new Array(10);

3 Create Array object Store values (data) Another way to create Array
array_name[i] = value; (i= 0,1,2…n) shopping_list[i] = “car”; Another way to create Array var array_name = new Array(value1, value2, …, valueN); var shopping_list = new Array(“Car”, “PDA”, “mp3 player”);

4 Operators Comparison Operators Logical Operators
==, !=, >, <, >= , <= Logical Operators &&(AND), || (OR), ! (NOT) These operator are used to write the conditions in conditional and repetitive statements

5 Conditional Statement
Conditional statement allows different actions or code to be executed based on validity of condition If Statement Syntax If( ) Semantics Evaluate the condition (true or false) If the condition is true True: DO STATEMENT False: SKIP the STATEMENT Condition STATEMENT

6 Conditional Statement
If…else statement Syntax: If( ) else Semantics: Evaluate condition If the condition is, True: Do STATEMENT 1 False: Do STATEMENT 2 Condition STATEMENT 1 STATEMENT 2

7 Using setInterval() JavaScript can execute in response to a timer event Write up the code you would like to be executed multiple times at a regular interval Use the setInterval of the window class Example: window.setInterval(“code to be executed”, 1000);


Download ppt "JavaScript Create Array object"

Similar presentations


Ads by Google