SlideShare a Scribd company logo
1 of 39
JavaScript : Objects OlehKelompok 11 DewandraDanishwara 5108100060 HariPrasetyo 5108100063 AnrisaPriyasta 5108100100 PatrisiusArdiantoCahyadi 5108100184
JavaScript/Jscript: Objects Outline 13.1	Introduction 13.2	Thinking About Objects 13.3	Math Object 13.4	String Object 	13.4.1	Fundamentals of Characters and Strings 	13.4.1	Methods of the String Object 	13.4.3	Character Processing Methods 	13.4.4	Searching Methods 	13.4.5	Splitting Strings and Obtaining Substrings 	12.4.6	HTML Markup Methods 13.5	Date Object 13.6	Boolean and Number Objects
Sekarang JavaScript digunakanuntukmenggambarkankonsep-konseppemrogramandasar JavaScript dapatjugamemanipulasisetiapelemendarisebuahdokumen HTML darisebuahskrip Dalambabini Akandiberikancara formal penanganan object Ikhtisardanfungsidari Beberapa JavaScript object yang sudahada Menunjukkankemampuanmereka 13.1 Introduction
JavaScript – bahasapemrogramanberbasis object Objects Duakategori Animate Inanimate Attribut Behaviors Merangkumdata danmethods Properti: Penyembunyianinformasi Komunikasidengan program Melaluiinterfaces Kebanyakanperangkatlunakmasadepanakandibangundenganmenggabungkanobjek 13.2 Thinking About Objects
Menggunakanobjek JavaScript untuk Berinteraksidenganelemen (atauobjek) darisebuahdokumen HTML object window Memungkinkan script untukmemanipulasi window browser window.status window.alert object document Menyediakanakseskesetiapelemendarisebuahdokumen HTML Merangkumberbagaikemampuandalam script object array Memungkinkan script untukmemanipulasikoleksi data 13.2 Thinking About Objects (II)
13.3 Math Object Method pada object math Memungkinkan programmer untukmelakukanberbagaiperhitunganmatematikaumum Propertidari object Math
13.3 Math Object (II) Method yang seringdigunakanpada object Math
Object String JavaScript string dancharacter kapabilitasproses Sesuaiuntukmengembangkan Text editors Word processors Page layout software Computerized typesetting systems Jenisperangkatlunakpengolahteks 13.4 String Object
Characters Merupakandasardari program JavaScript String Seri dariCharacters yang dianggapsebagaisatu unit Mungkintermasuk Letters Digits Special Characters +, _, /, $, etc. 13.4.1 Fundamentals of Characters and Strings
String literals / string constant Ditulissebagaiurutankarakterdalamurutantunggalatautandakutipganda Strings mungkindiisikanpadavariabelsaatdeklarasi var color = “blue”; String dapatdibandingkandengan Relational operators Equality operators 13.4.1 Fundamentals of Characters and Strings
13.4.2 Methods of the String Object String object Merangkum atribut dan behaviour karakter string Format untukmemanggil method stringName.methodName( ); Method yang adadigunakanuntuk Memilihkarakterdarisuatu string Menggabungkan string (concatenation) Mendapatkan substring darisebuah string Mencari substring dalam string Mengkonversi string ke semua huruf besar atau huruf kecil Menghasilkan tag HTML
13.4.2 Methods of the String Object (II)
12.4.3 Character Processing Methods
1.1 Initialize and assign strings to variables 2.1 Print text and call charAt method 3.1 Print text and call charCodeAt method 4.1 Print text and call String.fromCharCode method 5.1 Print text and call toLowerCase method 6.1 Print text and call toUppercase method 	1	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 	2	<HTML> 	3	<!-- Fig. 13.4: CharacterProcessing.html --> 	4	 	5	<HEAD> 	6	<TITLE>Character Processing Methods</TITLE> 	7	 	8	<SCRIPT LANGUAGE ="JavaScript"> 	9	var s = "ZEBRA"; 	10	var s2 = "AbCdEfG"; 	11	 	12	   document.writeln( "<P>Character at index 0 in '" +  	13	      s + "' is " + s.charAt( 0 ) ); 	14	document.writeln( "<BR>Character code at index 0 in '" +  	15	      s + "' is " + s.charCodeAt( 0 ) + "</P>" );  	16	 	17	   document.writeln( "<P>'" +  	18	      String.fromCharCode( 87, 79, 82, 68 ) +  	19	      "' contains character codes 87, 79, 82 and 68</P>" ) 	20	 	21	   document.writeln( "<P>'" + s2 + "' in lowercase is '" + 	22	      s2.toLowerCase() + "'" );        	23	   document.writeln( "<BR>'" + s2 + "' in uppercase is '" + 	24	      s2.toUpperCase() + "'</P>" );        	25	</SCRIPT> 	26	 	27	</HEAD><BODY></BODY> 	28	</HTML>
Script Output
13.4.4 Searching Methods Seringkalibergunauntukmencarikarakteratauurutankarakterdalam string
1.1 Initialize and assign string to variable 2.1 Define buttonPressed function 2.2 Run indexOf method and output result 2.3 Run lastIndexOf method and ouput result 2.4 Run indexOf method with index arg. and ouput result 2.5 Run lastIndexOf method with index arg. and ouput result 	1	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 	2	<HTML> 	3	<!-- Fig. 13.5: SearchingStrings.html --> 	4	 	5	<HEAD> 	6	<TITLE>Searching Strings with indexOf and lastIndexOf</TITLE> 	7	 	8	<SCRIPT LANGUAGE ="JavaScript"> 	9	var letters = "abcdefghijklmnopqrstuvwxyzabcdefghijklm"; 	10	 	11	function buttonPressed()  	12	   { 	13	      searchForm.first.value =  	14	         letters.indexOf( searchForm.inputVal.value ); 	15	      searchForm.last.value =  	16	         letters.lastIndexOf( searchForm.inputVal.value ); 	17	      searchForm.first12.value =  	18	         letters.indexOf( searchForm.inputVal.value, 12 ); 	19	      searchForm.last12.value =  	20	         letters.lastIndexOf( searchForm.inputVal.value, 12 ); 	21	   } 	22	</SCRIPT> 	23	 	24	</HEAD>
3.1 Open HTML FORM 3.2 Print text 3.3 Insert and define searching INPUT elements 3.4 Insert and define output INPUT elements 3.5 Close FORM 34<P>First occurrence located at index  35<INPUT NAME = "first"TYPE ="text"SIZE = "5"> 36<BR>Last occurrence located at index 37<INPUT NAME ="last" TYPE ="text"SIZE ="5"> 38<BR>First occurrence from index 12 located at index  39<INPUT NAME ="first12"TYPE ="text"SIZE ="5"> 40  <BR>Last occurrence from index 12 located at index 41<INPUT NAME = "last12"TYPE ="text"SIZE ="5"></P> 42</FORM> 43</BODY> 44</HTML> 25<BODY> 26<FORM NAME = "searchForm"> 27<H1>The string to search is:<BR> 28       abcdefghijklmnopqrstuvwxyzabcdefghijklm</H1> 29<P>Enter substring to search for  30<INPUT NAME ="inputVal" TYPE = "text"> 31<INPUT NAME ="search"TYPE ="button"VALUE ="Search"  32ONCLICK ="buttonPressed()"><BR></P> 33
Script Output 1
Script Output 2
Ketikaandamembacakalimat Pisahkanhinggamenjadikata– kataatau token Prosespemecahan string menjadi token adalahtokenisasi Jugadilakukanolehintreperter Token dipisahkanolehdelimiters Biasanyawhite-space karakter Karakter lain dapatdigunakan HasildaritokenisasiditampilkandiTEXTAREAkomponen GUI 13.4.5 Splitting Strings and Obtaining Substrings
13.4.5 Splitting Strings and Obtaining Substrings (II)
1.1 Define splitButtonPressed function 1.2 Initialize variable with split method 1.3 Output results 1.4 Run substring method and output results 	1	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 	2	<HTML> 	3	<!-- Fig. 13.6: SplitAndSubString.html --> 	4	 	5	<HEAD> 	6	<TITLE>String Method split and substring</TITLE> 	7	 	8	<SCRIPT LANGUAGE ="JavaScript"> 	9	function splitButtonPressed()  	10	   {   	11	var strings = myForm.inputVal.value.split( " " );   	12	      myForm.output.value = strings.join( "" );  	13	 	14	      myForm.outputSubstring.value =  	15	         myForm.inputVal.value.substring( 0, 10 );         	16	   } 	17	</SCRIPT> 	18	</HEAD> 	19
2.1 Open HTML FORM 2.2 Enter text and INPUT elements to be run by script 2.3 Enter text and INPUT elements to display results 2.4 Close FORM 33</P> 34</FORM> 35</BODY> 36</HTML> 20<BODY> 21<FORM NAME = "myForm"> 22<P>Enter a sentence to split into words<BR> 23 <INPUT NAME ="inputVal"TYPE ="text"SIZE ="40"> 24<INPUT NAME ="splitButton"TYPE ="button"VALUE ="Split" 25 ONCLICK = "splitButtonPressed()"></P> 26 27<P>The sentence split into words is<BR> 28<TEXTAREA NAME ="output"ROWS ="8" COLS = "34"> 29</TEXTAREA></P> 30 31 <P>The first 10 characters of the input string are 32<INPUT NAME ="outputSubstring" TYPE ="text"SIZE ="15">
Script Output
13.4.6 HTML Markup Methods
1.1 Initialize and assign strings to variables 	1	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 	2	<HTML> 	3	<!-- Fig. 13.7: MarkupMethods.html --> 	4	 	5	<HEAD> 	6	<TITLE>HTML Markup Methods of the String Object</TITLE> 	7	 	8	<SCRIPT LANGUAGE ="JavaScript"> 	9	var anchorText = "This is an anchor", 	10	       bigText = "This is big text", 	11	       blinkText = "This is blinking text", 	12	       boldText = "This is bold text", 	13	       fixedText = "This is monospaced text", 	14	       fontColorText = "This is red text", 	15	       fontSizeText = "This is size 7 text", 	16	       italicText = "This is italic text", 	17	       linkText = "Click here to go to anchorText", 	18	       smallText = "This is small text", 	19	       strikeText = "This is strike out text", 	20	       subText = "subscript", 	21	       supText = "superscript"; 	22
2.1 Print modified string variables using string methods 	34	   document.writeln( 	35	      "<BR>This is text with a " + subText.sub() );     	36	   document.writeln(  	37	      "<BR>This is text with a " + supText.sup() );     	38	   document.writeln( "<BR>" + linkText.link( "#top" ) );     	39	</SCRIPT> 	40	 	41	</HEAD><BODY></BODY> 	42	</HTML> 	23	   document.writeln( anchorText.anchor( "top" ) );     	24	   document.writeln( "<BR>" + bigText.big() );     	25	   document.writeln( "<BR>" + blinkText.blink() );     	26	   document.writeln( "<BR>" + boldText.bold() );     	27	   document.writeln( "<BR>" + fixedText.fixed() );     	28	   document.writeln(  	29	      "<BR>" + fontColorText.fontcolor( "red" ) );     	30	   document.writeln( "<BR>" + fontSizeText.fontsize( 7 ) ); 	31	   document.writeln( "<BR>" + italicText.italics() );     	32	   document.writeln( "<BR>" + smallText.small() );     	33	   document.writeln( "<BR>" + strikeText.strike() );
Script Output
13.5 Date Object ObjekDate JavaScript Menyediakan method untukmemanipulasitanggaldanwaktu Pemrosesantanggaldanwaktudapatdilakukanberdasarkan Local time zone Universal Coordinated Time (UTC) /  	Greenwich Mean Time (GMT) Sebagianbesar method dalamobjekDate memilikiwaktulokaldanversi UTC BilamenggunakanobjekDate InisialisasiobjekDatedenganwaktusekarang var current = new Date();  Allokasikanmemory untukobject, panggilkonstruktorobjekDate Constructor – initializer method for an object
PembuatanobjekbaruDate new Date( year, month, date, hours, 		minutes, seconds, milliseconds ); Jam, menit, detikand milidetikadalah optional Jikaargumendikanansudahditentukan, semuaargumendikirijugaharusditentukan Month represented internally as integers from 0-11 Therefore, March is indicated by 2, November by 10, etc. Penulisantahundalambentuk 4-digit(‘2000’, bukan ’00’) MenghindarikemungkinantimbulnyamasalahY2K 13.5 Date Object (II)
Dua method lain dapatdipanggiltanpamembuatobjekDatebaru Kedua method menghasilkanangkamilisekondiantaratengahmalam, January 1, 1970 dantanggal yang ditentukanolehargumen Date.parse( argument ); Argument Bentuktanggalpendek MM-DD-YY, MM-DD-YYYY, MM/DD/YY, MM/DD/YYYY Bentuktanggalpanjang Bulan (paling sedikitduahurufpertama), tanggaldantahun Waktudalam format 12 atau24 jam 13.5 Date Object (III)
Date.UTC( argument ); Argument – samasepertikonstruktorDate ( Y, M, D, H, M, S, M ) Method tersebutdapatdiubahmenjadiobjekDate vartheDate = new Date(numberOfMilliseconds ); numberOfMillisecondssamadenganhasildariDate.UTCatauDate.Parse 13.5 Date Object (IV)
1.1 Call Date constructor with no arguments and assign to variable 2.1 Print date and time info using methods from the Date object  2.2 Print methods for local time zone  	1	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 	2	<HTML> 	3	<!-- Fig. 13.9: DateTime.html --> 	4	 	5	<HEAD> 	6	<TITLE>Date and Time Methods</TITLE> 	7	 	8	<SCRIPT LANGUAGE ="JavaScript"> 	9	var current = new Date(); 	10	 	11	   document.writeln(  	12	      "<H1>String representations and valueOf</H1>" ); 	13	   document.writeln( "toString: " + current.toString() +  	14	      "<BR>toLocaleString: " + current.toLocaleString() +  	15	      "<BR>toUTCString: " + current.toUTCString() +  	16	      "<BR>valueOf: " + current.valueOf() ); 	17	 	18	   document.writeln( 	19	      "<H1>Get methods for local time zone</H1>" ); 	20	   document.writeln( "getDate: " + current.getDate() + 	21	      "<BR>getDay: " + current.getDay() +   	22	      "<BR>getMonth: " + current.getMonth() +     	23	      "<BR>getFullYear: " + current.getFullYear() +     	24	      "<BR>getTime: " + current.getTime() +     	25	      "<BR>getHours: " + current.getHours() +     	26	      "<BR>getMinutes: " + current.getMinutes() +     	27	      "<BR>getSeconds: " + current.getSeconds() +     	28	      "<BR>getMilliseconds: " + current.getMilliseconds() +  	29	      "<BR>getTimezoneOffset: " +  	30	      current.getTimezoneOffset() );   	31
3.1 Set new Date 3.2 Print new Date information 4.1 Set methods for local time zone 4.2 Print modified date for local time zone 	34	var anotherDate = new Date( 1999, 2, 18, 1, 5, 0, 0 ); 	35	   document.writeln( "Date: " + anotherDate ); 	36	 	37	   document.writeln( 	38	      "<H1>Set methods for local time zone</H1>" );  	39	   anotherDate.setDate( 31 );  	40	   anotherDate.setMonth( 11 ); 	41	   anotherDate.setFullYear( 1999 ); 	42	   anotherDate.setHours( 23 ); 	43	   anotherDate.setMinutes( 59 ); 	44	   anotherDate.setSeconds( 59 ); 	45	   document.writeln( "Modified date: " + anotherDate ); 	46	</SCRIPT> 	47	 	48	</HEAD><BODY></BODY> 	49	</HTML> 	32	   document.writeln( 	33	      "<H1>Specifying arguments for a new Date</H1>" );
Script Output
BooleandanobjekNumber Disediakansebagaipembungkusobjekuntuk Nilai Boolean true/false  Numbers Wrapper mendefinisikan method danproperti yang bergunadalammemanipulasinilaibooleandan number Objek Number JavaScript secaraotomatismembuatobjekNumberuntukmenyimpannilainumerik Programmer dapatmembuatobjekNumberdengan var n = new Number( numericValue); 13.6 Boolean and Number Objects
Objek Boolean Ketikanilaibooleandibutuhkadalamsebuah program, secaraotomatisakandibuatoleh JavaScript untukmenyimpannilaitersebutkedalamobjekBoolean Programmer dapatmembuatobjekBooleansecaraeksplisit var b = new Boolean( booleanValue ); If booleanvalue equals false, 0, null, Number.NaN or empty string (“ ”) Objek Booleanberisifalse Otherwise Objek Booleanberisitrue 13.6 Boolean and Number Objects (II)
13.6 Boolean and Number Objects (III) Methods of the Boolean Object

More Related Content

Viewers also liked

Cuento el cumpleaños de las flores
Cuento el cumpleaños de las floresCuento el cumpleaños de las flores
Cuento el cumpleaños de las flores
profe 1
 
Guida alla modifica del dsdt 1a parte - le basi
Guida alla modifica del dsdt   1a parte - le basiGuida alla modifica del dsdt   1a parte - le basi
Guida alla modifica del dsdt 1a parte - le basi
guest1842a5
 

Viewers also liked (14)

Efficienza energetica e nuove convergenze
Efficienza energetica e nuove convergenzeEfficienza energetica e nuove convergenze
Efficienza energetica e nuove convergenze
 
Clevercoyotebilingue 2
Clevercoyotebilingue 2Clevercoyotebilingue 2
Clevercoyotebilingue 2
 
Cuento el cumpleaños de las flores
Cuento el cumpleaños de las floresCuento el cumpleaños de las flores
Cuento el cumpleaños de las flores
 
COMPARATIVE ANALYSIS OF BULGARIA, GEORGIA AND SPAIN - EXPORTING FRUITS & VEG...
COMPARATIVE ANALYSIS  OF BULGARIA, GEORGIA AND SPAIN - EXPORTING FRUITS & VEG...COMPARATIVE ANALYSIS  OF BULGARIA, GEORGIA AND SPAIN - EXPORTING FRUITS & VEG...
COMPARATIVE ANALYSIS OF BULGARIA, GEORGIA AND SPAIN - EXPORTING FRUITS & VEG...
 
Guida alla modifica del dsdt 1a parte - le basi
Guida alla modifica del dsdt   1a parte - le basiGuida alla modifica del dsdt   1a parte - le basi
Guida alla modifica del dsdt 1a parte - le basi
 
Guía de apoyo a la docencia SEM-01
Guía de apoyo a la docencia SEM-01Guía de apoyo a la docencia SEM-01
Guía de apoyo a la docencia SEM-01
 
JUnit Boot Camp (GeeCON 2016)
JUnit Boot Camp (GeeCON 2016)JUnit Boot Camp (GeeCON 2016)
JUnit Boot Camp (GeeCON 2016)
 
Code Retreat Venice (2016)
Code Retreat Venice (2016)Code Retreat Venice (2016)
Code Retreat Venice (2016)
 
Refactoring the Tennis Kata v2 (2016)
Refactoring the Tennis Kata v2 (2016)Refactoring the Tennis Kata v2 (2016)
Refactoring the Tennis Kata v2 (2016)
 
Mob Programming (2016)
Mob Programming (2016)Mob Programming (2016)
Mob Programming (2016)
 
Designing Test Cases for the Gilded Rose Kata v3 (2016)
Designing Test Cases for the Gilded Rose Kata v3 (2016)Designing Test Cases for the Gilded Rose Kata v3 (2016)
Designing Test Cases for the Gilded Rose Kata v3 (2016)
 
Coding Dojo: Asynchronous Clock-In (2016)
Coding Dojo: Asynchronous Clock-In (2016)Coding Dojo: Asynchronous Clock-In (2016)
Coding Dojo: Asynchronous Clock-In (2016)
 
Coding Dojo: Data Munging (2016)
Coding Dojo: Data Munging (2016)Coding Dojo: Data Munging (2016)
Coding Dojo: Data Munging (2016)
 
EXPORTING PORTUGUESE SHRIMP TO FRANCE
EXPORTING PORTUGUESE SHRIMP TO FRANCEEXPORTING PORTUGUESE SHRIMP TO FRANCE
EXPORTING PORTUGUESE SHRIMP TO FRANCE
 

Similar to tugas_PW_[11]

Week32
Week32Week32
Week32
H K
 
Week32
Week32Week32
Week32
H K
 
We9 Struts 2.0
We9 Struts 2.0We9 Struts 2.0
We9 Struts 2.0
wangjiaz
 
Web Developement Workshop (Oct 2009) Slides
Web Developement Workshop (Oct 2009) SlidesWeb Developement Workshop (Oct 2009) Slides
Web Developement Workshop (Oct 2009) Slides
Manish Sinha
 
02. session 02 working with html elements
02. session 02   working with html elements02. session 02   working with html elements
02. session 02 working with html elements
Phúc Đỗ
 
Html and i_phone_mobile-2
Html and i_phone_mobile-2Html and i_phone_mobile-2
Html and i_phone_mobile-2
tonvanbart
 

Similar to tugas_PW_[11] (20)

Everything You Always Wanted To Know About XML But Were Afraid To Ask
Everything You Always Wanted To Know About XML But Were Afraid To AskEverything You Always Wanted To Know About XML But Were Afraid To Ask
Everything You Always Wanted To Know About XML But Were Afraid To Ask
 
Week32
Week32Week32
Week32
 
Week32
Week32Week32
Week32
 
Significant Characteristics In Planets Manfred Thaller
Significant Characteristics In Planets Manfred ThallerSignificant Characteristics In Planets Manfred Thaller
Significant Characteristics In Planets Manfred Thaller
 
Xml encryption
Xml encryptionXml encryption
Xml encryption
 
Lecture 2 - Comm Lab: Web @ ITP
Lecture 2 - Comm Lab: Web @ ITPLecture 2 - Comm Lab: Web @ ITP
Lecture 2 - Comm Lab: Web @ ITP
 
OpenSocial - GTUG Stockholm Meeting Oct 1 2009
OpenSocial - GTUG Stockholm Meeting Oct 1 2009OpenSocial - GTUG Stockholm Meeting Oct 1 2009
OpenSocial - GTUG Stockholm Meeting Oct 1 2009
 
Javascript: Ajax & DOM Manipulation v1.2
Javascript: Ajax & DOM Manipulation v1.2Javascript: Ajax & DOM Manipulation v1.2
Javascript: Ajax & DOM Manipulation v1.2
 
We9 Struts 2.0
We9 Struts 2.0We9 Struts 2.0
We9 Struts 2.0
 
Struts2
Struts2Struts2
Struts2
 
Web Developement Workshop (Oct 2009) Slides
Web Developement Workshop (Oct 2009) SlidesWeb Developement Workshop (Oct 2009) Slides
Web Developement Workshop (Oct 2009) Slides
 
Presentasi Kelompok 25 PW A+B
Presentasi Kelompok 25 PW A+BPresentasi Kelompok 25 PW A+B
Presentasi Kelompok 25 PW A+B
 
Tugas pw [kelompok 25]
Tugas pw [kelompok 25]Tugas pw [kelompok 25]
Tugas pw [kelompok 25]
 
Using Forms in Share
Using Forms in ShareUsing Forms in Share
Using Forms in Share
 
02. session 02 working with html elements
02. session 02   working with html elements02. session 02   working with html elements
02. session 02 working with html elements
 
Maker All - Executive Presentation
Maker All - Executive PresentationMaker All - Executive Presentation
Maker All - Executive Presentation
 
Html and i_phone_mobile-2
Html and i_phone_mobile-2Html and i_phone_mobile-2
Html and i_phone_mobile-2
 
JQuery 101
JQuery 101JQuery 101
JQuery 101
 
Tugas Pw [6]
Tugas Pw [6]Tugas Pw [6]
Tugas Pw [6]
 
Tugas Pw [6] (2)
Tugas Pw [6] (2)Tugas Pw [6] (2)
Tugas Pw [6] (2)
 

Recently uploaded

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
fonyou31
 

Recently uploaded (20)

General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 

tugas_PW_[11]

  • 1. JavaScript : Objects OlehKelompok 11 DewandraDanishwara 5108100060 HariPrasetyo 5108100063 AnrisaPriyasta 5108100100 PatrisiusArdiantoCahyadi 5108100184
  • 2. JavaScript/Jscript: Objects Outline 13.1 Introduction 13.2 Thinking About Objects 13.3 Math Object 13.4 String Object 13.4.1 Fundamentals of Characters and Strings 13.4.1 Methods of the String Object 13.4.3 Character Processing Methods 13.4.4 Searching Methods 13.4.5 Splitting Strings and Obtaining Substrings 12.4.6 HTML Markup Methods 13.5 Date Object 13.6 Boolean and Number Objects
  • 3. Sekarang JavaScript digunakanuntukmenggambarkankonsep-konseppemrogramandasar JavaScript dapatjugamemanipulasisetiapelemendarisebuahdokumen HTML darisebuahskrip Dalambabini Akandiberikancara formal penanganan object Ikhtisardanfungsidari Beberapa JavaScript object yang sudahada Menunjukkankemampuanmereka 13.1 Introduction
  • 4. JavaScript – bahasapemrogramanberbasis object Objects Duakategori Animate Inanimate Attribut Behaviors Merangkumdata danmethods Properti: Penyembunyianinformasi Komunikasidengan program Melaluiinterfaces Kebanyakanperangkatlunakmasadepanakandibangundenganmenggabungkanobjek 13.2 Thinking About Objects
  • 5. Menggunakanobjek JavaScript untuk Berinteraksidenganelemen (atauobjek) darisebuahdokumen HTML object window Memungkinkan script untukmemanipulasi window browser window.status window.alert object document Menyediakanakseskesetiapelemendarisebuahdokumen HTML Merangkumberbagaikemampuandalam script object array Memungkinkan script untukmemanipulasikoleksi data 13.2 Thinking About Objects (II)
  • 6. 13.3 Math Object Method pada object math Memungkinkan programmer untukmelakukanberbagaiperhitunganmatematikaumum Propertidari object Math
  • 7. 13.3 Math Object (II) Method yang seringdigunakanpada object Math
  • 8. Object String JavaScript string dancharacter kapabilitasproses Sesuaiuntukmengembangkan Text editors Word processors Page layout software Computerized typesetting systems Jenisperangkatlunakpengolahteks 13.4 String Object
  • 9. Characters Merupakandasardari program JavaScript String Seri dariCharacters yang dianggapsebagaisatu unit Mungkintermasuk Letters Digits Special Characters +, _, /, $, etc. 13.4.1 Fundamentals of Characters and Strings
  • 10. String literals / string constant Ditulissebagaiurutankarakterdalamurutantunggalatautandakutipganda Strings mungkindiisikanpadavariabelsaatdeklarasi var color = “blue”; String dapatdibandingkandengan Relational operators Equality operators 13.4.1 Fundamentals of Characters and Strings
  • 11. 13.4.2 Methods of the String Object String object Merangkum atribut dan behaviour karakter string Format untukmemanggil method stringName.methodName( ); Method yang adadigunakanuntuk Memilihkarakterdarisuatu string Menggabungkan string (concatenation) Mendapatkan substring darisebuah string Mencari substring dalam string Mengkonversi string ke semua huruf besar atau huruf kecil Menghasilkan tag HTML
  • 12. 13.4.2 Methods of the String Object (II)
  • 14. 1.1 Initialize and assign strings to variables 2.1 Print text and call charAt method 3.1 Print text and call charCodeAt method 4.1 Print text and call String.fromCharCode method 5.1 Print text and call toLowerCase method 6.1 Print text and call toUppercase method 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 2 <HTML> 3 <!-- Fig. 13.4: CharacterProcessing.html --> 4 5 <HEAD> 6 <TITLE>Character Processing Methods</TITLE> 7 8 <SCRIPT LANGUAGE ="JavaScript"> 9 var s = "ZEBRA"; 10 var s2 = "AbCdEfG"; 11 12 document.writeln( "<P>Character at index 0 in '" + 13 s + "' is " + s.charAt( 0 ) ); 14 document.writeln( "<BR>Character code at index 0 in '" + 15 s + "' is " + s.charCodeAt( 0 ) + "</P>" ); 16 17 document.writeln( "<P>'" + 18 String.fromCharCode( 87, 79, 82, 68 ) + 19 "' contains character codes 87, 79, 82 and 68</P>" ) 20 21 document.writeln( "<P>'" + s2 + "' in lowercase is '" + 22 s2.toLowerCase() + "'" ); 23 document.writeln( "<BR>'" + s2 + "' in uppercase is '" + 24 s2.toUpperCase() + "'</P>" ); 25 </SCRIPT> 26 27 </HEAD><BODY></BODY> 28 </HTML>
  • 16. 13.4.4 Searching Methods Seringkalibergunauntukmencarikarakteratauurutankarakterdalam string
  • 17. 1.1 Initialize and assign string to variable 2.1 Define buttonPressed function 2.2 Run indexOf method and output result 2.3 Run lastIndexOf method and ouput result 2.4 Run indexOf method with index arg. and ouput result 2.5 Run lastIndexOf method with index arg. and ouput result 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 2 <HTML> 3 <!-- Fig. 13.5: SearchingStrings.html --> 4 5 <HEAD> 6 <TITLE>Searching Strings with indexOf and lastIndexOf</TITLE> 7 8 <SCRIPT LANGUAGE ="JavaScript"> 9 var letters = "abcdefghijklmnopqrstuvwxyzabcdefghijklm"; 10 11 function buttonPressed() 12 { 13 searchForm.first.value = 14 letters.indexOf( searchForm.inputVal.value ); 15 searchForm.last.value = 16 letters.lastIndexOf( searchForm.inputVal.value ); 17 searchForm.first12.value = 18 letters.indexOf( searchForm.inputVal.value, 12 ); 19 searchForm.last12.value = 20 letters.lastIndexOf( searchForm.inputVal.value, 12 ); 21 } 22 </SCRIPT> 23 24 </HEAD>
  • 18. 3.1 Open HTML FORM 3.2 Print text 3.3 Insert and define searching INPUT elements 3.4 Insert and define output INPUT elements 3.5 Close FORM 34<P>First occurrence located at index 35<INPUT NAME = "first"TYPE ="text"SIZE = "5"> 36<BR>Last occurrence located at index 37<INPUT NAME ="last" TYPE ="text"SIZE ="5"> 38<BR>First occurrence from index 12 located at index 39<INPUT NAME ="first12"TYPE ="text"SIZE ="5"> 40 <BR>Last occurrence from index 12 located at index 41<INPUT NAME = "last12"TYPE ="text"SIZE ="5"></P> 42</FORM> 43</BODY> 44</HTML> 25<BODY> 26<FORM NAME = "searchForm"> 27<H1>The string to search is:<BR> 28 abcdefghijklmnopqrstuvwxyzabcdefghijklm</H1> 29<P>Enter substring to search for 30<INPUT NAME ="inputVal" TYPE = "text"> 31<INPUT NAME ="search"TYPE ="button"VALUE ="Search" 32ONCLICK ="buttonPressed()"><BR></P> 33
  • 21. Ketikaandamembacakalimat Pisahkanhinggamenjadikata– kataatau token Prosespemecahan string menjadi token adalahtokenisasi Jugadilakukanolehintreperter Token dipisahkanolehdelimiters Biasanyawhite-space karakter Karakter lain dapatdigunakan HasildaritokenisasiditampilkandiTEXTAREAkomponen GUI 13.4.5 Splitting Strings and Obtaining Substrings
  • 22. 13.4.5 Splitting Strings and Obtaining Substrings (II)
  • 23. 1.1 Define splitButtonPressed function 1.2 Initialize variable with split method 1.3 Output results 1.4 Run substring method and output results 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 2 <HTML> 3 <!-- Fig. 13.6: SplitAndSubString.html --> 4 5 <HEAD> 6 <TITLE>String Method split and substring</TITLE> 7 8 <SCRIPT LANGUAGE ="JavaScript"> 9 function splitButtonPressed() 10 { 11 var strings = myForm.inputVal.value.split( " " ); 12 myForm.output.value = strings.join( "" ); 13 14 myForm.outputSubstring.value = 15 myForm.inputVal.value.substring( 0, 10 ); 16 } 17 </SCRIPT> 18 </HEAD> 19
  • 24. 2.1 Open HTML FORM 2.2 Enter text and INPUT elements to be run by script 2.3 Enter text and INPUT elements to display results 2.4 Close FORM 33</P> 34</FORM> 35</BODY> 36</HTML> 20<BODY> 21<FORM NAME = "myForm"> 22<P>Enter a sentence to split into words<BR> 23 <INPUT NAME ="inputVal"TYPE ="text"SIZE ="40"> 24<INPUT NAME ="splitButton"TYPE ="button"VALUE ="Split" 25 ONCLICK = "splitButtonPressed()"></P> 26 27<P>The sentence split into words is<BR> 28<TEXTAREA NAME ="output"ROWS ="8" COLS = "34"> 29</TEXTAREA></P> 30 31 <P>The first 10 characters of the input string are 32<INPUT NAME ="outputSubstring" TYPE ="text"SIZE ="15">
  • 27. 1.1 Initialize and assign strings to variables 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 2 <HTML> 3 <!-- Fig. 13.7: MarkupMethods.html --> 4 5 <HEAD> 6 <TITLE>HTML Markup Methods of the String Object</TITLE> 7 8 <SCRIPT LANGUAGE ="JavaScript"> 9 var anchorText = "This is an anchor", 10 bigText = "This is big text", 11 blinkText = "This is blinking text", 12 boldText = "This is bold text", 13 fixedText = "This is monospaced text", 14 fontColorText = "This is red text", 15 fontSizeText = "This is size 7 text", 16 italicText = "This is italic text", 17 linkText = "Click here to go to anchorText", 18 smallText = "This is small text", 19 strikeText = "This is strike out text", 20 subText = "subscript", 21 supText = "superscript"; 22
  • 28. 2.1 Print modified string variables using string methods 34 document.writeln( 35 "<BR>This is text with a " + subText.sub() ); 36 document.writeln( 37 "<BR>This is text with a " + supText.sup() ); 38 document.writeln( "<BR>" + linkText.link( "#top" ) ); 39 </SCRIPT> 40 41 </HEAD><BODY></BODY> 42 </HTML> 23 document.writeln( anchorText.anchor( "top" ) ); 24 document.writeln( "<BR>" + bigText.big() ); 25 document.writeln( "<BR>" + blinkText.blink() ); 26 document.writeln( "<BR>" + boldText.bold() ); 27 document.writeln( "<BR>" + fixedText.fixed() ); 28 document.writeln( 29 "<BR>" + fontColorText.fontcolor( "red" ) ); 30 document.writeln( "<BR>" + fontSizeText.fontsize( 7 ) ); 31 document.writeln( "<BR>" + italicText.italics() ); 32 document.writeln( "<BR>" + smallText.small() ); 33 document.writeln( "<BR>" + strikeText.strike() );
  • 30. 13.5 Date Object ObjekDate JavaScript Menyediakan method untukmemanipulasitanggaldanwaktu Pemrosesantanggaldanwaktudapatdilakukanberdasarkan Local time zone Universal Coordinated Time (UTC) / Greenwich Mean Time (GMT) Sebagianbesar method dalamobjekDate memilikiwaktulokaldanversi UTC BilamenggunakanobjekDate InisialisasiobjekDatedenganwaktusekarang var current = new Date(); Allokasikanmemory untukobject, panggilkonstruktorobjekDate Constructor – initializer method for an object
  • 31. PembuatanobjekbaruDate new Date( year, month, date, hours, minutes, seconds, milliseconds ); Jam, menit, detikand milidetikadalah optional Jikaargumendikanansudahditentukan, semuaargumendikirijugaharusditentukan Month represented internally as integers from 0-11 Therefore, March is indicated by 2, November by 10, etc. Penulisantahundalambentuk 4-digit(‘2000’, bukan ’00’) MenghindarikemungkinantimbulnyamasalahY2K 13.5 Date Object (II)
  • 32. Dua method lain dapatdipanggiltanpamembuatobjekDatebaru Kedua method menghasilkanangkamilisekondiantaratengahmalam, January 1, 1970 dantanggal yang ditentukanolehargumen Date.parse( argument ); Argument Bentuktanggalpendek MM-DD-YY, MM-DD-YYYY, MM/DD/YY, MM/DD/YYYY Bentuktanggalpanjang Bulan (paling sedikitduahurufpertama), tanggaldantahun Waktudalam format 12 atau24 jam 13.5 Date Object (III)
  • 33. Date.UTC( argument ); Argument – samasepertikonstruktorDate ( Y, M, D, H, M, S, M ) Method tersebutdapatdiubahmenjadiobjekDate vartheDate = new Date(numberOfMilliseconds ); numberOfMillisecondssamadenganhasildariDate.UTCatauDate.Parse 13.5 Date Object (IV)
  • 34. 1.1 Call Date constructor with no arguments and assign to variable 2.1 Print date and time info using methods from the Date object 2.2 Print methods for local time zone 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 2 <HTML> 3 <!-- Fig. 13.9: DateTime.html --> 4 5 <HEAD> 6 <TITLE>Date and Time Methods</TITLE> 7 8 <SCRIPT LANGUAGE ="JavaScript"> 9 var current = new Date(); 10 11 document.writeln( 12 "<H1>String representations and valueOf</H1>" ); 13 document.writeln( "toString: " + current.toString() + 14 "<BR>toLocaleString: " + current.toLocaleString() + 15 "<BR>toUTCString: " + current.toUTCString() + 16 "<BR>valueOf: " + current.valueOf() ); 17 18 document.writeln( 19 "<H1>Get methods for local time zone</H1>" ); 20 document.writeln( "getDate: " + current.getDate() + 21 "<BR>getDay: " + current.getDay() + 22 "<BR>getMonth: " + current.getMonth() + 23 "<BR>getFullYear: " + current.getFullYear() + 24 "<BR>getTime: " + current.getTime() + 25 "<BR>getHours: " + current.getHours() + 26 "<BR>getMinutes: " + current.getMinutes() + 27 "<BR>getSeconds: " + current.getSeconds() + 28 "<BR>getMilliseconds: " + current.getMilliseconds() + 29 "<BR>getTimezoneOffset: " + 30 current.getTimezoneOffset() ); 31
  • 35. 3.1 Set new Date 3.2 Print new Date information 4.1 Set methods for local time zone 4.2 Print modified date for local time zone 34 var anotherDate = new Date( 1999, 2, 18, 1, 5, 0, 0 ); 35 document.writeln( "Date: " + anotherDate ); 36 37 document.writeln( 38 "<H1>Set methods for local time zone</H1>" ); 39 anotherDate.setDate( 31 ); 40 anotherDate.setMonth( 11 ); 41 anotherDate.setFullYear( 1999 ); 42 anotherDate.setHours( 23 ); 43 anotherDate.setMinutes( 59 ); 44 anotherDate.setSeconds( 59 ); 45 document.writeln( "Modified date: " + anotherDate ); 46 </SCRIPT> 47 48 </HEAD><BODY></BODY> 49 </HTML> 32 document.writeln( 33 "<H1>Specifying arguments for a new Date</H1>" );
  • 37. BooleandanobjekNumber Disediakansebagaipembungkusobjekuntuk Nilai Boolean true/false Numbers Wrapper mendefinisikan method danproperti yang bergunadalammemanipulasinilaibooleandan number Objek Number JavaScript secaraotomatismembuatobjekNumberuntukmenyimpannilainumerik Programmer dapatmembuatobjekNumberdengan var n = new Number( numericValue); 13.6 Boolean and Number Objects
  • 38. Objek Boolean Ketikanilaibooleandibutuhkadalamsebuah program, secaraotomatisakandibuatoleh JavaScript untukmenyimpannilaitersebutkedalamobjekBoolean Programmer dapatmembuatobjekBooleansecaraeksplisit var b = new Boolean( booleanValue ); If booleanvalue equals false, 0, null, Number.NaN or empty string (“ ”) Objek Booleanberisifalse Otherwise Objek Booleanberisitrue 13.6 Boolean and Number Objects (II)
  • 39. 13.6 Boolean and Number Objects (III) Methods of the Boolean Object