Javascript data structures

Slides:



Advertisements
Similar presentations
JavaScript Part 6. Calling JavaScript functions on an event JavaScript doesn’t have a main function like other programming languages but we can imitate.
Advertisements

Tutorial 12 Working with Arrays, Loops, and Conditional Statements
2 Alerts and the If/Else Conditional Statement CONTINUED There's No Right Way to Do It There are, literally, a million ways to write any given script.
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
Arrays – What is it? – Creation – Changing the contents Functions – What is it? – Syntax – How they work – Anonymous functions A quick lesson in Objects.
CHAPTER 4 Java Script อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา 1.
Project 1: Using Arrays and Manipulating Strings Essentials for Design JavaScript Level Two Michael Brooks.
10 – Java Script (3) Informatics Department Parahyangan Catholic University.
Introduction To JavaScript. Putting it Together (page 11) All javascript must go in-between the script tags. All javascript must go in-between the script.
INTERNET APPLICATIONS CPIT405 JavaScript Instructor: Rasha AlOmari
PH2150 Scientific Computing Skills Control Structures in Python In general, statements are executed sequentially, top to bottom. There are many instances.
Austin Texas. 7 Day Forecast Sunday – 62 /51 Sunday – 62 /51 Monday – 65 / 45 Monday – 65 / 45 Tuesday – 56 / 36 Tuesday – 56 / 36 Wednesday – 56 / 43.
Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do this.
Today is Monday, today is Monday
Web Systems & Technologies
Sunday Monday Tuesday Wednesday Thursday Friday Saturday
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
Days of the week NEXT.
SEEM4570 Tutorial 05: JavaScript as OOP
Chapter 6: Conditional Statements and Loops
Expressions and Control Flow in JavaScript
Week#2 Day#1 Java Script Course
Days of the Week Les docs d’Estelle –
JavaScript: Array, Loop, Data File
DAYS OF THE WEEK.
Objectives Create an array Work with array properties and methods
Time management School of Rock.
CMPE 152: Compiler Design September 18 Class Meeting
A Class Calendar in PowerPoint
JANUARY 2018 SUNDAY MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY
Sunday Monday Tuesday Wednesday Sunday Monday Tuesday Wednesday
WHO IS THE BEST? Ашық сабақ тақырыбы: ағылшын тілі пәнінің мұғалімі:
The switch Statement Topics Multiple Selection switch Statement
Tutorial 4 JavaScript as OOP Li Xu
MY FUNDAY.
Objectives In this chapter, you will:
FIZZ FREE FEBRUARY 2019 Your name: Your school:
Reading Calendar: Hatchet by Gary Paulson
Microsoft Visual Basic 2005: Reloaded Second Edition
Days of the Week Monday Tuesday Wednesday Friday Thursday Saturday
Unit 1: Quick Quizzes After 5,13
Reading Calendar: Hatchet by Gary Paulson
SEPTEMBER 2014 Unit 1 Unit 1 Unit 1 Unit 1 Quick Quiz 9,16, 21 Unit 1
SEPTEMBER ½ Day Unit PLC
BIT116: Scripting Lecture 6 Part 1
JANUARY 2018 SUNDAY MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY
Unit 3 Year 2 – Part B Lesson 1 - Practice.
Extended Christmas Hours Thursday December 8th 9am -6:30pm Friday December 9th 9am -6:30pm Saturday December 10th 9am-6pm Thursday December.
January 2015 Sunday Monday Tuesday Wednesday Thursday Friday Saturday
| January Sunday Monday Tuesday Wednesday Thursday Friday
Welcome to the Library.
At Least Two-Thirds Of The Top 10 Trending Topics
Author visit- Patricia Polacco
Time 1.
冀教版 六年级下册 Lesson 9 Eat More Vegetables and Fruit!.
Contact
#teacher5aday Stress Awareness Month
Control Structures contd… Selection
NOVEMBER READING LOG Student: When you have read, record your minutes and have your parent initial the proper box (each day). At the end of the month,
DECEMBER READING LOG Student: When you have read, record your minutes and have your parent initial the proper box (each day). At the end of the month,
WEEK 1 Monday Tuesday Wednesday Thursday Friday Saturday Sunday
2011年 5月 2011年 6月 2011年 7月 2011年 8月 Sunday Monday Tuesday Wednesday
June Sunday Monday Tuesday Wednesday Thursday Friday Saturday
March 2008 Sunday Monday Tuesday Wednesday Thursday Friday Saturday 1

*Dates subject to change
BOOKINGS – Monday, 2nd July BAYWAVE
SEEM 4540 Tutorial 4 Basic PHP based on w3Schools
Mr. Butler 6th Grade Earth Science
January Monday Tuesday Wednesday Thursday Friday Saturday Sunday 30 31
Presentation transcript:

Javascript data structures A.G.Malamos

Loops for(var i = numberToStart; i < aNumberOfYourChoice; i++ ) { ...code you want to repeat; } var mySetToUse= { set item 1, set item 2, set item 3}; var txt = ""; for (var x in mySetToUse) { ...code you want to repeat; example txt += mySetToUse[x]; }

while (condition) {     ...code you want to repeat; } do {    ...code you want to repeat; } while (condition);

Array as a stack … push and pop array.push(item1, item2, ..., itemX) var fruits = ["Banana", "Orange", "Apple", "Mango"]; fruits.push("Kiwi", "lemon"); The result of fruits will be: Banana,Orange,Apple,Mango,Kiwi,lemon Example from: www.w3schools.com

array.pop() <script> var fruits = ["Banana", "Orange", "Apple", "Mango"]; function myFunction() { var x=fruits.pop(); document.getElementById("demo").innerHTML = x; } </script> Will write in HTML Mango <script> var fruits = ["Banana", "Orange", "Apple", "Mango"]; document.getElementById("demo").innerHTML = fruits; function myFunction() { fruits.pop(); } </script> Will write in HTML Banana, Orange

array.splice(index, howmany, item1, ....., itemX) index Required. An integer that specifies at what position to add/remove items, Use negative values to specify the position from the end of the array howmany Optional. The number of items to be removed. If set to 0, no items will be removed item1, ..., itemX Optional. The new item(s) to be added to the array <script> var fruits = ["Banana", "Orange", "Apple", "Mango"]; document.getElementById("demo").innerHTML = fruits; function myFunction() { fruits.splice(2, 0, "Lemon", "Kiwi"); } </script> This code will write in HTML Banana,Orange,Lemon,Kiwi,Apple,Mango

Switch case switch(expression) { case n: code block break; default: } switch (new Date().getDay()) {     case 0:         day = "Sunday";         break;     case 1:         day = "Monday";         break;     case 2:         day = "Tuesday";         break;     case 3:         day = "Wednesday";         break;     case 4:         day = "Thursday";         break;     case 5:         day = "Friday";         break;     case 6:         day = "Saturday"; } switch(expression) { case n: code block break; default: }

Matching text …indexOf() and lastIndexOf() theInitialString.indexOf(aStringToSearchFor, characterNumberTostart); Returns the index of the first character of the string aStringToSearchFor in the theInitialString The lastIndexOf() method returns the position of the last occurrence of aStringToSearchFor in a string theInitialString. Both methods return -1 if the value to search for never occurs. Both methods are case sensitive