1 / 11

CSC318 – WEB APPLICATION DEVELOPMENT

CSC318 – WEB APPLICATION DEVELOPMENT. BY: MUHD EIZAN SHAFIQ BIN ABD AZIZ FACULTY of COMPUTER and MATHEMATICAL SCIENCES. Outline. JavaScript Array & Objects. JavaScript Array JavaScript Objects JavaScript Math Object JavaScript Date & Time Object. Javascript Array. Array.

chars
Télécharger la présentation

CSC318 – WEB APPLICATION DEVELOPMENT

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSC318 – WEB APPLICATION DEVELOPMENT BY: MUHD EIZAN SHAFIQ BIN ABD AZIZ FACULTY of COMPUTER and MATHEMATICAL SCIENCES

  2. Outline JavaScript Array & Objects • JavaScript Array • JavaScript Objects • JavaScript Math Object • JavaScript Date & Time Object FSKM UiTM Pahang  Page 2

  3. Javascript Array Array • What is an array? • Temporary (storage|memory) of similar data • Has 1 variable • Store a group of data • Text • Numbers • images FSKM UiTM Pahang  Page 3

  4. Array Javascript Array • Example <script type="text/javascript"> // declare an array var stud_name = new Array(); // assign values on stud_name array stud_name[0] = "Anwar"; stud_name[1] = "Azlin"; stud_name[2] = "Asmaa'"; stud_name[3] = "Ezatul Najwa"; stud_name[4] = "Fauziyah"; /* Another method var stud_name = new Array("anwar","azlin","asmaa"); */ </script> FSKM UiTM Pahang  Page 4

  5. JavaScript Objects Basic Object in JavaScript <script language="javascript"> // create js object var person = new Object(); // assign values to object properties person.fullname = "Harun Salim Bachik"; person.age = 45; person.gender = "Male"; </script> FSKM UiTM Pahang  Page 5

  6. JavaScript Objects JavaScript Math Object • JavaScript provides four mathematical functions. Some of them are: • random(): return a random number between 0 and 1 • round(): round a number to the nearest integer • max(x, y): return larger number between x and y • min(y, y): return smaller number between x and y • pow(x, y): return xy • To use all the functions, it must starts with Math.<math_function> FSKM UiTM Pahang  Page 6

  7. JavaScript Objects JavaScript Math Object <script type="text/javascript"> document.write(Math.random()); document.write("<br><br>"); document.write(Math.round(45.2)); document.write("<br><br>"); document.write("Max is: " + Math.max(14, 7)); document.write("<br><br>"); document.write("Min is: " + Math.min(14, 7)); document.write("<br><br>"); document.write("10<sup>10</sup>: " + Math.pow(10, 2)); </script> FSKM UiTM Pahang  Page 7

  8. JavaScript Objects Javascript Date & Time Object <script language="javascript"> var now = new Date(); var day = now.getDate(); var month = now.getMonth() + 1; var year = now.getYear(); if(year < 1000) year = year + 1900; var fullDate = day + "/" + month + "/" + year; document.write("Today's date is: " + fullDate); </script> FSKM UiTM Pahang  Page 8

  9. JavaScript Objects Javascript Date & Time Object <script language="javascript"> var now = new Date(); var hour = now.getHours(); var minute = now.getMinutes(); var second = now.getSeconds(); document.write("Current time is " + hour + ":"); document.write(minute + ":"); document.write(second); </script> FSKM UiTM Pahang  Page 9

  10. Question? FSKM UiTM Pahang  Page 10

  11. Knuckles (2001). Introduction to Interactive Programming on the Internet using HTML & Javascript. John Wiley & Sons, Inc. http://www.w3schools.com/js/default.asp http://www.javascriptkit.com/jsref/math.shtml Bibliography (Book) Bibliography (Website) FSKM UiTM Pahang  Page 11

More Related