Pertemuan 12 JavaScript.

Slides:



Advertisements
Similar presentations
Pertemuan 12.  Create an array  For...In Statement  Join two arrays - concat()  Put array elements into a string - join()  Literal array - sort()
Advertisements

JavaScript Part 6. Calling JavaScript functions on an event JavaScript doesn’t have a main function like other programming languages but we can imitate.
SQL Pertemuan 26. Range Operator ‘Between dan Not Between’
25-Jun-15 JavaScript Language Fundamentals II. 2 Exception handling, I Exception handling in JavaScript is almost the same as in Java throw expression.
JavaScript Switch Statement. Switch JavaScript Switch Statement If you have a lot of conditions, you can use a switch statement instead of an if…elseif…
Array Object. he following code creates an Array object called myCars: 1: var myCars=new Array(); // regular array (add an optional integer myCars[0]="Saab";
Loops Doing the same thing over and over and over and over and over and over…
JavaScript & DOM Client-side scripting. JavaScript JavaScript is a tool to automate client side (which is implemented using HTML so far) JavaSript syntax.
CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad GM-IT CIIT Islamabad CIIT Virtual Campus, CIIT COMSATS Institute.
Javascript. Outline Introduction Fundamental of JavaScript Javascript events management DOM and Dynamic HTML (DHTML)
JavaScript For...In Statement The for...in statement loops through the elements of an array or through the properties of an object. Syntax for (variable.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
CHAPTER 4 Java Script อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา 1.
Cpan240 JavaScript Guest Lecture 2. Objectives JavaScript Operators –Calculation Conversions –Comparison Operators –Logical operators –Bitwise Operators.
Outline if...else...elseif Statements Switch Loops Functions Arrays Forms.
PHP. PHP User Defined Functions Besides the built-in PHP functions, we can create our own functions. A function is a block of statements that can be used.
JavaScript. JavaScript is the programming language of HTML and the Web. Easy to learn One of the 3 languages of all developers MUST learn: 1. HTML to.
Pertemuan 5 IT133 Pengembangan Web JavaScript. What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting.
In God we trust Learning Java Script. Java Script JavaScript is the scripting language of the Web! JavaScript is used in millions of Web pages to improve.
 An array stores multiple values in one single variable.  Example: Output: I like Honda Civic, BMW and Toyota.
Chapter 5 Murach's JavaScript and jQuery, C1© 2012, Mike Murach & Associates, Inc.Slide 1.
INTERNET APPLICATIONS CPIT405 JavaScript Instructor: Rasha AlOmari
Wavelet Coherence & Cross-Wavelet Transform
Hui Wang†*, Canturk Isci‡, Lavanya Subramanian*,
The Latent Power of Absurd Ideas (aka Robust Query Processing)
Instructor: Shengyu Zhang
Chapter 2 – Algebra II 02 Learning Outcomes
On behalf of the FCC Other Magnets Task
Calorimetry.
Properties of Materials Electrical Properties
7.1 Zero and Negative Exponents:
Limited Dependent Variables
You must learn this for your GCSE
Pertemuan 3 JavaScript.
PHP Built-In Functions
Build in Objects In JavaScript, almost "everything" is an object.
Pemrograman WEB I Pertemuan 4.
Web Systems & Technologies
LOOPING DAN FUNCTION Pertemuan 5.
Pertemuan 7 JavaScript.
HTML & teh internets.
JavaScript - Errors & Exceptions Handling
PHP Functions Besides the built-in PHP functions, we can create our own functions. A function is a block of statements that can be used repeatedly in.
Javascript Short Introduction By Thanawat Varintree,
JavaScript.
JavaScript Objects.
JavaScript Functions and Arrays
JavaScript and Ajax (Expression and Operators)
JavaScript: Arrays.
Web Systems Development (CSC-215)
BY: SITI NURBAYA ISMAIL FACULTY of COMPUTER and MATHEMATICAL SCIENCES
ARRAYS MIT-AITI Copyright 2001.
يمكن استدعاء الكود الوظيفي عند حدث معين أو عند استدعاء الكود الوظيفي .
Introduction to DOM.
Pertemuan 11 JavaScript.
Javascript: variables and parameters
Pertemuan 3 JavaScript.
Pertemuan 10 JavaScript.
يمكن استدعاء الكود الوظيفي عند حدث معين أو عند استدعاء الكود الوظيفي .
JavaScript Arrays.
Web Programming Language
Lect2 (MCS/BCS) Javascript.
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.
Pertemuan 13 JavaScript.
Pertemuan 10 JavaScript.
Tutorial 10: Programming with javascript
BIT116: Scripting Functions.
The <script> Tag
JAVASCRIPT HOW TO PROGRAM -2
INFO/CSE 100, Spring 2006 Fluency in Information Technology
Presentation transcript:

Pertemuan 12 JavaScript

Array Object Create an array For...In Statement Join two arrays - concat() Put array elements into a string - join() Literal array - sort() Numeric array - sort()

Create an array <html> <body> <script type="text/javascript"> var mycars = new Array(); mycars[0] = "Saab"; mycars[1] = "Volvo"; mycars[2] = "BMW"; for (i=0;i<mycars.length;i++) { document.write(mycars[i] + "<br />"); } </script> </body> </html> Saab Volvo BMW

For...In Statement <html> <body> <script type="text/javascript"> var x; var mycars = new Array(); mycars[0] = "Saab"; mycars[1] = "Volvo"; mycars[2] = "BMW"; for (x in mycars) { document.write(mycars[x] + "<br />"); } </script> </body> </html> Saab Volvo BMW

Join two arrays - concat() <html> <body> <script type="text/javascript"> var arr = new Array(3); arr[0] = "Jani"; arr[1] = "Tove"; arr[2] = "Hege"; var arr2 = new Array(3); arr2[0] = "John"; arr2[1] = "Andy"; arr2[2] = "Wendy"; document.write(arr.concat(arr2)); </script> </body> </html> Jani,Tove,Hege,John,Andy,Wendy

Put array elements into a string - join() <html> <body> <script type="text/javascript"> var arr = new Array(3); arr[0] = "Jani"; arr[1] = "Hege"; arr[2] = "Stale"; document.write(arr.join() + "<br />"); document.write(arr.join(".")); </script> </body> </html> Jani,Hege,Stale Jani.Hege.Stale

Literal array - sort() <html> <body> <script type="text/javascript"> var arr = new Array(6); arr[0] = "Jani"; arr[1] = "Hege"; arr[2] = "Stale"; arr[3] = "Kai Jim"; arr[4] = "Borge"; arr[5] = "Tove"; document.write(arr + "<br />"); document.write(arr.sort()); </script> </body> </html> Jani,Hege,Stale,Kai Jim,Borge,Tove Borge,Hege,Jani,Kai Jim,Stale,Tove

Numeric array - sort() <html> <body> <script type="text/javascript"> function sortNumber(a, b) { return a - b; } var arr = new Array(6); arr[0] = "10"; arr[1] = "5"; arr[2] = "40"; arr[3] = "25"; arr[4] = "1000"; arr[5] = "1"; document.write(arr + "<br />"); document.write(arr.sort(sortNumber)); </script> </body> </html> 10,5,40,25,1000,1 1,5,10,25,40,1000

Tugas Buat Program mengolah data yang terrdiri dari Kode dan Nama Barang; Contoh; 005 Pensil 003 Pena 001 Buku 002 Mistar 004 Penghapus 006 Spidol Output yang diminta 2 macam, tersusun berdasarkan kode barang dan tersusun berdasarkan nama barang. Gunakan Array.