<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2065822655831694480</id><updated>2024-08-31T04:45:47.224-07:00</updated><category term="English Tutorial"/><category term="C Sharp"/><category term="Tutorial Bhs Indo"/><category term="Solved Problem"/><category term="Javascript"/><category term="Sharepoint"/><category term="Tutorial Blog"/><title type='text'>Web Sharing Ilmu</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://armoe.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default'/><link rel='alternate' type='text/html' href='http://armoe.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02277756216508959449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>18</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2065822655831694480.post-8471960429567777942</id><published>2016-06-17T16:01:00.001-07:00</published><updated>2016-06-17T16:03:09.170-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="Tutorial Bhs Indo"/><title type='text'>Objek pada Javascript</title><content type='html'>&lt;h1 style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: &amp;quot;Open Sans&amp;quot;, Calibri, Candara, Arial, sans-serif; font-size: 39px; font-weight: 300; line-height: 1.1; margin: 21px 0px 10.5px;&quot;&gt;
Objek pada Javascript&lt;a class=&quot;headerlink&quot; href=&quot;https://bertzzie.com/knowledge/javascript/Objek-pada-Javascript.html#objek-pada-javascript&quot; style=&quot;background: transparent; box-sizing: border-box; color: #007fff; text-decoration: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h1&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: &amp;quot;Open Sans&amp;quot;, Calibri, Candara, Arial, sans-serif; font-size: 15px; line-height: 21.4286px; margin-bottom: 10.5px;&quot;&gt;
Javascript memiliki dua jenis tipe data utama, yaitu tipe data dasar dan objek. Tipe data dasar pada Javascript adalah angka (&lt;em style=&quot;box-sizing: border-box;&quot;&gt;numbers&lt;/em&gt;), rentetan karakter (&lt;em style=&quot;box-sizing: border-box;&quot;&gt;strings&lt;/em&gt;), boolean (&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;true&lt;/span&gt;&lt;/code&gt;&amp;nbsp;dan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;false&lt;/span&gt;&lt;/code&gt;),&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;null&lt;/span&gt;&lt;/code&gt;, dan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;undefined&lt;/span&gt;&lt;/code&gt;. Nilai-nilai selain tipe data dasar secara otomatis dianggap sebagai objek. Objek dalam Javascript didefinisikan sebagai&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;mutable properties collection&lt;/em&gt;, yang artinya adalah sekumpulan properti (ciri khas) yang dapat berubah nilainya. Karena nilai-nilai selain tipe data dasar merupakan objek, maka pada Javascript sebuah Array adalah objek. Fungsi adalah objek.&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Regular expression&lt;/em&gt;&amp;nbsp;juga adalah objek. Segala tipe buatan pengembang tentunya juga adalah objek.&lt;/div&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: &amp;quot;Open Sans&amp;quot;, Calibri, Candara, Arial, sans-serif; font-size: 15px; line-height: 21.4286px; margin-bottom: 10.5px;&quot;&gt;
Objek Javascript terdiri dari banyak properti. Masing-masing properti ini digunakan untuk mendeskripsikan objek tersebut. Sebuah properti idealnya berhubungan langsung dan mendeskripsikan objek dengan jelas. Misalkan, objek&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;Mahasiswa&lt;/span&gt;&lt;/code&gt;&amp;nbsp;biasanya akan memiliki properti&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;NoInduk&lt;/span&gt;&lt;/code&gt;&amp;nbsp;dan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;Nama&lt;/span&gt;&lt;/code&gt;&amp;nbsp;tetapi tidak memiliki properti&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;JumlahBaju&lt;/span&gt;&lt;/code&gt;&amp;nbsp;karena nomor induk dan nama berguna untuk mendeskripsikan mahasiswa, sementara jumlah baju tidak penting. Contoh lainnya adalah objek&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;Mobil&lt;/span&gt;&lt;/code&gt;&amp;nbsp;yang mungkin memiliki properti&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;WarnaBadan&lt;/span&gt;&lt;/code&gt;&amp;nbsp;dan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;NoPolisi&lt;/span&gt;&lt;/code&gt;&amp;nbsp;tetapi tidak memiliki properti&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;JumlahKaki&lt;/span&gt;&lt;/code&gt;.&lt;/div&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: &amp;quot;Open Sans&amp;quot;, Calibri, Candara, Arial, sans-serif; font-size: 15px; line-height: 21.4286px; margin-bottom: 10.5px;&quot;&gt;
Properti pada objek memiliki nama dan nilai dari properti tersebut. Nama dari properti menjelaskan nilai yang disimpan oleh properti tersebut. Pada contoh sebelumnya,&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;WarnaBadan&lt;/span&gt;&lt;/code&gt;&amp;nbsp;adalah nama dari properti. Nilai dari properti merupakan “isi” dari nama properti. Contoh dari nilai pada&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;WarnaBadan&lt;/span&gt;&lt;/code&gt;&amp;nbsp;adalah&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;Merah&lt;/span&gt;&lt;/code&gt;&amp;nbsp;atau&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;#FF0000&lt;/span&gt;&lt;/code&gt;. Nama dari properti harus berupa string, dan boleh berisi string kosong. Nilai dari properti lebih bebas, yaitu dapat berupa nilai apapun kecuali undefined. Hal ini berarti kita dapat mengisikan properti dengan nilai bertipe number, boolean, string, null, dan objek.&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;pembuatan-objek-pada-javascript&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: &amp;quot;Open Sans&amp;quot;, Calibri, Candara, Arial, sans-serif; font-size: 15px; line-height: 21.4286px;&quot;&gt;
&lt;h2 style=&quot;box-sizing: border-box; color: inherit; font-size: 32px; font-weight: 300; line-height: 1.1; margin-bottom: 10.5px; margin-top: 21px;&quot;&gt;
Pembuatan Objek pada Javascript&lt;a class=&quot;headerlink&quot; href=&quot;https://bertzzie.com/knowledge/javascript/Objek-pada-Javascript.html#pembuatan-objek-pada-javascript&quot; style=&quot;background: transparent; box-sizing: border-box; color: #007fff; text-decoration: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Objek pada Javascript bersifat&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;class-free&lt;/em&gt;. Hal ini berarti kita tidak wajib mendefinisikan kelas terlebih dahulu agar dapat menggunakan sebuah objek (melalui inisiasi /&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;constructor). Jika pada bahasa pemrograman lain (misalnya :code:`C#`) untuk membuat objek baru kita **harus*&lt;/em&gt;&amp;nbsp;terlebih dahulu membuat kelas dari objek tersebut dan kemudian menggunakannya seperti berikut:&lt;/div&gt;
&lt;div class=&quot;highlight-csharp&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// deklarasi kelas&lt;/span&gt;
&lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot; style=&quot;box-sizing: border-box; color: #0e84b5; font-weight: bold;&quot;&gt;Mobil&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;WarnaBadan&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// properti lain&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// penggunaan kelas&lt;/span&gt;
&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: #902000;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;mercedes&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;Mobil&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// gunakan kelas...&lt;/span&gt;
&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;mercedes&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;WarnaBadan&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;Merah&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
maka pada Javascript kita tidak perlu mendefinisikan kelas terlebih dahulu untuk membuat objek. Notasi pembuatan objek pada Javascript sangat sederhana: sepasang kurung kurawal yang membungkus properti. Notasi pembuatan objek ini dikenal dengan nama&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;object literal&lt;/em&gt;. Object literal dapat digunakan kapanpun pada ekspresi Javascript yang valid:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2
3
4
5
6&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;objek_kosong&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{};&lt;/span&gt;

&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;mobil&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;warna-badan&quot;&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;merah&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;nomor-polisi&quot;&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;BK1234AB&quot;&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;};&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Nama properti dari sebuah objek harus berupa string, dan boleh berisi string kosong (&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/code&gt;). Jika merupakan nama Javascript yang legal, kita tidak memerleukan petik ganda pada nama properti. Petik ganda seperti pada contoh (&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;&quot;warna-badan&quot;&lt;/span&gt;&lt;/code&gt;) hanya diperlukan untuk nama Javascript ilegal atau kata kunci seperti “if” atau “var”. Misalnya,&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;&quot;nomor-polisi&quot;&lt;/span&gt;&lt;/code&gt;&amp;nbsp;memerlukan tanda petik, sementara&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;nomor_polisi&lt;/span&gt;&lt;/code&gt;&amp;nbsp;tidak. Contoh lain,&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;variasi&lt;/span&gt;&lt;/code&gt;&amp;nbsp;tidak memerlukan tanda petik, sementara&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;&quot;var&quot;&lt;/span&gt;&lt;/code&gt;&amp;nbsp;perlu.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Sebuah objek dapat menyimpan banyak properti, dan setiap properti dipisahkan dengan tanda koma (&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;&lt;/code&gt;). Jika ada banyak properti, nilai dari properti pada setiap objek boleh berbeda-beda:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2
3
4
5
6&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;jadwal&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;platform&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;34&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;telah_berangkat&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;tujuan&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;Medan&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;asal&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;Jakarta&quot;&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;};&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Karena dapat diisikan dengan nilai apapun (termasuk objek), maka kita dapat membuat objek yang mengandung objek lain (&lt;em style=&quot;box-sizing: border-box;&quot;&gt;nested object&lt;/em&gt;; objek bersarang) seperti berikut:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;jadwal&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;platform&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;34&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;telah_berangkat&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;asal&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;kode_kota&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;MDN&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama_kota&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;Medan&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;waktu&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;2013-12-29 14:00&quot;&lt;/span&gt;
    &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;},&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;tujuan&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;kode_kota&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;JKT&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama_kota&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;Jakarta&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;waktu&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;2013-12-29 17.30&quot;&lt;/span&gt;
    &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;};&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Perhatikan dan tandai objek&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;jadwal&lt;/span&gt;&lt;/code&gt;&amp;nbsp;dan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;mobil&lt;/span&gt;&lt;/code&gt;&amp;nbsp;yang baru saja kita buat, karena bagian selanjutnya dari bab ini akan terus menggunakan kedua objek ini.&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;akses-nilai-properti&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: &amp;quot;Open Sans&amp;quot;, Calibri, Candara, Arial, sans-serif; font-size: 15px; line-height: 21.4286px;&quot;&gt;
&lt;h2 style=&quot;box-sizing: border-box; color: inherit; font-size: 32px; font-weight: 300; line-height: 1.1; margin-bottom: 10.5px; margin-top: 21px;&quot;&gt;
Akses Nilai Properti&lt;a class=&quot;headerlink&quot; href=&quot;https://bertzzie.com/knowledge/javascript/Objek-pada-Javascript.html#akses-nilai-properti&quot; style=&quot;background: transparent; box-sizing: border-box; color: #007fff; text-decoration: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Akses nilai properti dapat dilakukan dengan dua cara, yaitu:&lt;/div&gt;
&lt;ol class=&quot;arabic simple&quot; style=&quot;box-sizing: border-box; margin-bottom: 10.5px; margin-top: 0px;&quot;&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Penggunaan kurung siku (&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;[]&lt;/span&gt;&lt;/code&gt;) setelah nama objek. Kurung siku kemudian diisikan dengan nama properti, yang harus berupa string. Cara ini biasanya digunakan untuk nama properti yang adalah nama ilegal atau kata kunci Javascript.&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Penggunaan tanda titik (&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;/code&gt;) setelah nama objek diikuti dengan nama properti. Notasi ini merupakan notasi yang umum digunakan pada bahasa pemrograman lainnya. Sayangnya kita tidak dapat menggunakan notasi ini untuk nama ilegal atau kata kunci Javascript.&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Contoh penggunaan kedua cara pemanggilan di atas adalah sebagai berikut:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;mobil&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;warna-badan&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// Hasil: &quot;merah&quot;&lt;/span&gt;
&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;jadwal&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;platform&lt;/span&gt;      &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// Hasil: 34&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Ingat bahwa meskipun kedua cara di atas dapat digunakan, umumnya kita lebih banyak menemukan cara kedua pada kode Javascript. Buku ini secara umum juga akan menggunakan notasi kedua, karena lebih banyak digunakan dan tidak ambigu dengan akses array.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Sebagai bahasa dinamis, Javascript tidak akan melemparkan pesan kesalahan jika kita mengakses properti yang tidak ada dalam objek. Kita akan menerima nilai&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;undefined&lt;/span&gt;&lt;/code&gt;&amp;nbsp;jika mengakses properti yang tidak ada:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;jadwal&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nomor_kursi&lt;/span&gt;   &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// Hasil: undefined&lt;/span&gt;
&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;mobil&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;jumlah-roda&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// Hasil: undefined&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Jika akan menyimpan nilai dalam variabel dan ingin memberikan nilai standar jika properti tidak ditemukan, kita dapat menggunakan operator&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;||&lt;/span&gt;&lt;/code&gt;:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;jumlah_roda&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;mobil&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;jumlah-roda&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// jumlah_roda === 4&lt;/span&gt;
&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nomor_kursi&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;jadwal&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nomor_kursi&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;A1&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// nomor_kursi === &quot;A1&quot;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Lebih jauh lagi, kita akan menerima pesan kesalahan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;TypeError&lt;/span&gt;&lt;/code&gt;&amp;nbsp;jika mencoba mengakses properti dari properti yang sudah tidak ada seperti berikut:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// TypeError: Cannot read property &#39;nama&#39; of undefined&lt;/span&gt;
&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;jadwal&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;maskapai&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Hal ini terjadi karena ketika pemanggilan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;jadwal.maskapai&lt;/span&gt;&lt;/code&gt;&amp;nbsp;Javascript memberikan nilai&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;undefined&lt;/span&gt;&lt;/code&gt;&amp;nbsp;karena memang&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;jadwal&lt;/span&gt;&lt;/code&gt;&amp;nbsp;tidak memiliki properti&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;maskapai&lt;/span&gt;&lt;/code&gt;. Ketika kita memanggil properti&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt;&lt;/code&gt;, maka pada dasarnya kita mencoba menjalankan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;undefined.nama&lt;/span&gt;&lt;/code&gt;, yang tentunya akan menghasilkan error.&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;undefined&lt;/span&gt;&lt;/code&gt;&amp;nbsp;sudah pasti tidak memiliki properti&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt;&lt;/code&gt;.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Untuk menanggulangi hal ini, kita dapat menggunakan operator&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;/code&gt;:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2
3&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;jadwal&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;maskapai&lt;/span&gt;                         &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// Hasil: undefined&lt;/span&gt;
&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;jadwal&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;maskapai&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt;                    &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// Hasil: TypeError&lt;/span&gt;
&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;jadwal&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;maskapai&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;jadwal&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;maskapai&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt; &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// Hasil: undefined&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Tentunya kita juga dapat mengkombinasikan kedua operator ini untuk memberikan nilai standar jika properti tidak ada:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// nama_maskapai === &quot;Garuda&quot;&lt;/span&gt;
&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama_maskapai&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;jadwal&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;maskapai&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;jadwal&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;maskapai&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;Garuda&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Walaupun kombinasi kedua operator di atas jarang ditemukan, tetapi biasanya kita setidaknya menggunakan operator&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;||&lt;/span&gt;&lt;/code&gt;&amp;nbsp;untuk memastikan aplikasi yang dikembangkan tidak langsung berhenti berjalan dan rusak hanya karena sebuah properti tidak ditemukan.&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;mengubah-nilai-properti&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: &amp;quot;Open Sans&amp;quot;, Calibri, Candara, Arial, sans-serif; font-size: 15px; line-height: 21.4286px;&quot;&gt;
&lt;h2 style=&quot;box-sizing: border-box; color: inherit; font-size: 32px; font-weight: 300; line-height: 1.1; margin-bottom: 10.5px; margin-top: 21px;&quot;&gt;
Mengubah Nilai Properti&lt;a class=&quot;headerlink&quot; href=&quot;https://bertzzie.com/knowledge/javascript/Objek-pada-Javascript.html#mengubah-nilai-properti&quot; style=&quot;background: transparent; box-sizing: border-box; color: #007fff; text-decoration: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Di awal bab, kita berkata bahwa objek adalah kumpulan properti yang nilainya dapat berubah. Cara mengubah nilai properti sama dengan bahasa pemrograman lain pada umumnya, yaitu dengan menggunakan operator&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;=&lt;/span&gt;&lt;/code&gt;:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;jadwal&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;platform&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Sifat dinamis Javascript lagi-lagi dapat dilihat ketika kita mencoba mengubah nilai dari properti yang tidak ada pada objek:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;mobil&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;jumlah-roda&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;mobil&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;bahan_bakar&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;Bensin&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Tidak akan ada pesan kesalahan pada kode di atas, karena Javascript akan langsung menambahkan kedua properti yang kita ingin ubah tersebut. Objek&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;mobil&lt;/span&gt;&lt;/code&gt;&amp;nbsp;sekarang akan menjadi seperti berikut:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2
3
4
5
6&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;mobil&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;warna-badan&quot;&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;merah&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;nomor-polisi&quot;&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;BK1234AB&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;jumlah-roda&quot;&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;bahan_bakar&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;Bensin&quot;&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;};&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Kemudahan untuk menambah (dan mengubah) nilai properti dari objek secara dinamis ini merupakan salah satu kelebihan utama dari Javascript. Pada bab-bab selanjutnya kita akan banyak menggunakan teknik ini, baik dalam pemrograman berorientasi objek maupun fungsional. Pastikan untuk mengerti bagian ini dengan baik agar dapat dengan mudah mempelajari bab-bab selanjutnya.&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;menghapus-properti&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: &amp;quot;Open Sans&amp;quot;, Calibri, Candara, Arial, sans-serif; font-size: 15px; line-height: 21.4286px;&quot;&gt;
&lt;h2 style=&quot;box-sizing: border-box; color: inherit; font-size: 32px; font-weight: 300; line-height: 1.1; margin-bottom: 10.5px; margin-top: 21px;&quot;&gt;
Menghapus Properti&lt;a class=&quot;headerlink&quot; href=&quot;https://bertzzie.com/knowledge/javascript/Objek-pada-Javascript.html#menghapus-properti&quot; style=&quot;background: transparent; box-sizing: border-box; color: #007fff; text-decoration: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Jika sudah tidak ingin menggunakan sebuah properti, kita dapat melakukan penghapusan terhadap properti tersebut dengan menggunakan operator&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;delete&lt;/span&gt;&lt;/code&gt;. Contoh penggunaannya adalah sebagai berikut:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2
3
4
5
6&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;mobil&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;bahan_bakar&lt;/span&gt;  &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// Hasil: &quot;Bensin&quot;&lt;/span&gt;

&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// hapus properti bahan_bakar dari mobil&lt;/span&gt;
&lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;delete&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;mobil&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;bahan_bakar&lt;/span&gt;

&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;mobil&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;bahan_bakar&lt;/span&gt;  &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// Hasil: undefined&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Untuk sekarang, kita belum melihat kegunaan penuh dari fitur penghapusan properti ini. Kita akan melihat kembali kegunaan dari penghapusan properti setelah mempelajari bagian selanjutnya, yaitu&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;Prototype&lt;/span&gt;&lt;/code&gt;.&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;prototype&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: &amp;quot;Open Sans&amp;quot;, Calibri, Candara, Arial, sans-serif; font-size: 15px; line-height: 21.4286px;&quot;&gt;
&lt;h2 style=&quot;box-sizing: border-box; color: inherit; font-size: 32px; font-weight: 300; line-height: 1.1; margin-bottom: 10.5px; margin-top: 21px;&quot;&gt;
Prototype&lt;a class=&quot;headerlink&quot; href=&quot;https://bertzzie.com/knowledge/javascript/Objek-pada-Javascript.html#prototype&quot; style=&quot;background: transparent; box-sizing: border-box; color: #007fff; text-decoration: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Pada bab sebelumnya kita telah beberapa kali mengatakan bagaimana Javascript menggunakan pendekatan yang berbeda dalam dukungannya terhadap pemrograman berorientasi objek. Jika bahasa lain pada umumnya menggunakan&lt;em style=&quot;box-sizing: border-box;&quot;&gt;class-based&lt;/em&gt;&amp;nbsp;OOP, Javascript menggunakan&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;prototype-based&lt;/em&gt;&amp;nbsp;OOP. Kita akan melihat apa maksud dari&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;prototype-based&lt;/em&gt;&amp;nbsp;OOP secara sekilas pada bagian ini. Pembahasan secara mendalam akan dilakukan pada bab selanjutnya, karena pembahasan&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;protoyped-based&lt;/em&gt;&amp;nbsp;OOP tak dapat lepas dari penggunaan fungsi.&lt;/div&gt;
&lt;div class=&quot;admonition note alert alert-info&quot; style=&quot;background-color: #9954bb; border-radius: 0px; border: none; box-sizing: border-box; color: white; margin-bottom: 10px; margin-top: 10px; padding: 7px;&quot;&gt;
&lt;div class=&quot;first admonition-title&quot; style=&quot;box-sizing: border-box; font-weight: bold; margin-right: 10px;&quot;&gt;
Note&lt;/div&gt;
&lt;div class=&quot;last&quot; style=&quot;box-sizing: border-box; margin-top: 5px;&quot;&gt;
Mulai dari bagian ini,&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Prototype-Based&lt;/em&gt;&amp;nbsp;OOP akan disingkat menjadi PBO saja, sementara&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Class-Based&lt;/em&gt;&amp;nbsp;OOP akan disingkat CBO. Hal ini dilakukan untuk menghemat ruang tulisan.&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
PBO lebih banyak berbicara tentang penggunaan kembali kode, yang mana pada CBO salah satu mekanisme utamanya adalah&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;inheritance&lt;/em&gt;. Pada CBO, ketika ingin menggunakan fitur&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;inheritance&lt;/em&gt;&amp;nbsp;biasanya kita harus membuat kelas dan kemudian melakukan penurunan dari kelas tersebut seperti berikut (contoh dalam bahasa&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;C#&lt;/span&gt;&lt;/code&gt;):&lt;/div&gt;
&lt;div class=&quot;highlight-csharp&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot; style=&quot;box-sizing: border-box; color: #0e84b5; font-weight: bold;&quot;&gt;Mobil&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// ..&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// Truk sebagai turunan dari Mobil&lt;/span&gt;
&lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot; style=&quot;box-sizing: border-box; color: #0e84b5; font-weight: bold;&quot;&gt;Truk&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;Mobil&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// Truk memiliki semua property dan method dari Mobil.&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// Penggunaan kelas Truk&lt;/span&gt;
&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: #902000;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;tronton&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;Truck&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// Truk juga adalah mobil&lt;/span&gt;
&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;Mobil&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;tronton&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;Truck&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;();&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Pada Javascript yang mengimplementasikan PBO kita tidak lagi perlu menuliskan kelas, dan langsung melakukan penurunan terhadap objek. Misalkan kita memiliki objek&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;mobil&lt;/span&gt;&lt;/code&gt;&amp;nbsp;yang sederhana seperti berikut:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2
3
4&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;mobil&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;Mobil&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;jumlahBan&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;4&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;};&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Kita dapat langsung menurunkan objek tersebut dengan menggunakan fungsi&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;Object.create&lt;/span&gt;&lt;/code&gt;&amp;nbsp;seperti berikut:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2
3&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;truk&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot; style=&quot;box-sizing: border-box; color: #007020;&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;mobil&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// truk.nama === &quot;Mobil&quot;&lt;/span&gt;
&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// truk.jumlahBan === 4&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;admonition note alert alert-info&quot; style=&quot;background-color: #9954bb; border-radius: 0px; border: none; box-sizing: border-box; color: white; margin-bottom: 10px; margin-top: 10px; padding: 7px;&quot;&gt;
&lt;div class=&quot;first admonition-title&quot; style=&quot;box-sizing: border-box; font-weight: bold; margin-right: 10px;&quot;&gt;
Note&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-top: 5px;&quot;&gt;
Fungsi&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;Object.create&lt;/span&gt;&lt;/code&gt;&amp;nbsp;merupakan fungsi baru yang terkadang tidak didukung oleh&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;browser&lt;/em&gt;&amp;nbsp;lama. Jika ingin menggunakan fungsi ini, kita dapat membuat fungsi sederhana yang mengimplementasikan fitur serupa seperti berikut:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 833px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2
3
4
5
6
7&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;typeof&lt;/span&gt; &lt;span class=&quot;nb&quot; style=&quot;box-sizing: border-box; color: #007020;&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;create&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;!==&lt;/span&gt; &lt;span class=&quot;s1&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&#39;function&#39;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nb&quot; style=&quot;box-sizing: border-box; color: #007020;&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;create&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;o&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;F&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{};&lt;/span&gt;
        &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;F&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;prototype&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;o&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;F&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;last&quot; style=&quot;box-sizing: border-box;&quot;&gt;
Tidak usah takut jika tidak mengerti sama sekali apa yang kita lakukan di atas. Bab selanjutnya akan membahas dengan detil cara kerja dari fungsi ini, dan kenapa fungsi ini diperlukan.&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Pada kasus ini,&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;mobil&lt;/span&gt;&lt;/code&gt;&amp;nbsp;dikatakan adalah&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;prototype&lt;/em&gt;&amp;nbsp;dari&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;truk&lt;/span&gt;&lt;/code&gt;. Segala nilai atau properti yang dimiliki oleh&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;mobil&lt;/span&gt;&lt;/code&gt;&amp;nbsp;secara otomatis akan juga dimiliki oleh&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;truk&lt;/span&gt;&lt;/code&gt;. Semua objek yang kita buat dalam Javascript juga secara otomatis merupakan turunan dari objek&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;Object.prototype&lt;/span&gt;&lt;/code&gt;, yang merupakan objek bawaan dari Javascript. Hal ini berarti&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;mobil&lt;/span&gt;&lt;/code&gt;, dan seluruh turunannya, adalah turunan dari&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;Object.prototype&lt;/span&gt;&lt;/code&gt;.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Hubungan antara turunan dan orang tua dari objek hanya berlaku untuk pengambilan nilai. Dalam contoh di atas, perubahan nilai pada properti di&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;truk&lt;/span&gt;&lt;/code&gt;&amp;nbsp;tidak akan mengubah nilai dari properti&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;mobil&lt;/span&gt;&lt;/code&gt;:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;truk&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;Tronton&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// mobil.nama tetap &quot;Mobil&quot;&lt;/span&gt;
&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;truk&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;jumlahBan&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;   &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// mobil.jumlahBan tetap 4&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Ketika objek turunan memanggil properti yang kosong, maka Javascript secara otomatis akan mencari nama properti tersebut pada prototype-nya, dan jika masih tidak ada, properti akan dicari pada prototype dari objek prototype objek. Hal ini akan terus berlangsung sampai pengecekan dilakukan terhadap&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;Object.prototype&lt;/span&gt;&lt;/code&gt;. Jika&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;Object.prototype&lt;/span&gt;&lt;/code&gt;&amp;nbsp;tidak memiliki properti tersebut juga, maka&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;undefined&lt;/span&gt;&lt;/code&gt;&amp;nbsp;akan dikembalikan. Misalnya jika kita memanggil properti yang memang kita tahu tidak ada pada&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;truk&lt;/span&gt;&lt;/code&gt;:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;truk&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;berat_maks&lt;/span&gt; &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// undefined&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Maka proses pemanggilan yang terjadi sampai kita mendapatkan nilai&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;undefined&lt;/span&gt;&lt;/code&gt;&amp;nbsp;adalah sebagai berikut:&lt;/div&gt;
&lt;ol class=&quot;arabic&quot; style=&quot;box-sizing: border-box; margin-bottom: 10.5px; margin-top: 0px;&quot;&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;
&lt;dl class=&quot;first docutils&quot; style=&quot;box-sizing: border-box; margin-bottom: 21px; margin-top: 0px !important;&quot;&gt;
&lt;dt style=&quot;box-sizing: border-box; font-weight: bold; line-height: 1.42857;&quot;&gt;Cek&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;truk.berat_maks&lt;/span&gt;&lt;/code&gt;.&lt;/dt&gt;
&lt;dd style=&quot;box-sizing: border-box; line-height: 1.42857; margin-bottom: 10px; margin-left: 0px; margin-top: 3px;&quot;&gt;&lt;ol class=&quot;first last loweralpha simple&quot; style=&quot;box-sizing: border-box; list-style: lower-alpha; margin-bottom: 0px; margin-top: 0px !important;&quot;&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Karena nilai tidak ada, cek orang tua dari&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;truk&lt;/span&gt;&lt;/code&gt;.&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Orang tua dari&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;truk&lt;/span&gt;&lt;/code&gt;&amp;nbsp;adalah&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;mobil&lt;/span&gt;&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;/dd&gt;&lt;/dl&gt;
&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;
&lt;dl class=&quot;first docutils&quot; style=&quot;box-sizing: border-box; margin-bottom: 21px; margin-top: 0px !important;&quot;&gt;
&lt;dt style=&quot;box-sizing: border-box; font-weight: bold; line-height: 1.42857;&quot;&gt;Cek&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;mobil.berat_maks&lt;/span&gt;&lt;/code&gt;.&lt;/dt&gt;
&lt;dd style=&quot;box-sizing: border-box; line-height: 1.42857; margin-bottom: 10px; margin-left: 0px; margin-top: 3px;&quot;&gt;&lt;ol class=&quot;first last loweralpha simple&quot; style=&quot;box-sizing: border-box; list-style: lower-alpha; margin-bottom: 0px; margin-top: 0px !important;&quot;&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Karena nilai tidak ada, cek orang tua dari&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;mobil&lt;/span&gt;&lt;/code&gt;.&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Orang tua dari&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;mobil&lt;/span&gt;&lt;/code&gt;&amp;nbsp;adalah&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;Object.prototype&lt;/span&gt;&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;/dd&gt;&lt;/dl&gt;
&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;
&lt;dl class=&quot;first docutils&quot; style=&quot;box-sizing: border-box; margin-bottom: 21px; margin-top: 0px !important;&quot;&gt;
&lt;dt style=&quot;box-sizing: border-box; font-weight: bold; line-height: 1.42857;&quot;&gt;Cek&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;Object.prototype.berat_maks&lt;/span&gt;&lt;/code&gt;.&lt;/dt&gt;
&lt;dd style=&quot;box-sizing: border-box; line-height: 1.42857; margin-bottom: 10px; margin-left: 0px; margin-top: 3px;&quot;&gt;&lt;ol class=&quot;first last loweralpha simple&quot; style=&quot;box-sizing: border-box; list-style: lower-alpha; margin-bottom: 0px; margin-top: 0px !important;&quot;&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Karena nilai tidak ada, kembalikan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;undefined&lt;/span&gt;&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;/dd&gt;&lt;/dl&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Proses penelusuran properti ke atas sampai pada&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;Object.prototype&lt;/span&gt;&lt;/code&gt;&amp;nbsp;ini dikenal dengan nama delegasi (&lt;em style=&quot;box-sizing: border-box;&quot;&gt;delegation&lt;/em&gt;). Kita dapat mencoba fitur delegasi ini misalnya dengan membuang properti dalam&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;truk&lt;/span&gt;&lt;/code&gt;, dan kemudian mengaksesnya melalui kembali. Nilai yang diberikan akan menjadi nilai properti tersebut milik&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;mobil&lt;/span&gt;&lt;/code&gt;:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;delete&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;truk&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;truk&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt;         &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// Hasil: &quot;Mobil&quot;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Pengecekan nilai prototype ini juga bersifat dinamis. Hal ini berarti ketika kita menambahkan properti baru dalam prototype, seluruh objek turunan prototype tersebut akan dapat mengakses properti barunya. Contoh:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;mobil&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;berat_maks&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;3.0&lt;/span&gt;
&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;truk&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;berat_maks&lt;/span&gt;        &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// Hasil: 3.0&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Sejauh ini fasilitas penggunaan kembali kode pada PBO yang kita lihat masih belum terlalu berbeda dengan pada CBO, kecuali di bagian yang sifatnya dinamis. Kita akan melihat kekuatan yang sebenarnya dari PBO pada bab selanjutnya, setelah selesai membahas fungsi.&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;penelusuran-nilai-properti&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: &amp;quot;Open Sans&amp;quot;, Calibri, Candara, Arial, sans-serif; font-size: 15px; line-height: 21.4286px;&quot;&gt;
&lt;h2 style=&quot;box-sizing: border-box; color: inherit; font-size: 32px; font-weight: 300; line-height: 1.1; margin-bottom: 10.5px; margin-top: 21px;&quot;&gt;
Penelusuran Nilai Properti&lt;a class=&quot;headerlink&quot; href=&quot;https://bertzzie.com/knowledge/javascript/Objek-pada-Javascript.html#penelusuran-nilai-properti&quot; style=&quot;background: transparent; box-sizing: border-box; color: #007fff; text-decoration: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Dengan menggunakan perulangan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;for&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;in&lt;/span&gt;&lt;/code&gt;&amp;nbsp;kita dapat melakukan penelusuran terhadap satu per satu properti objek. Penelusuran akan dilakukan terhadap seluruh nilai milik objek: properti,&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;method&lt;/em&gt;&amp;nbsp;(fungsi milik objek), maupun properti hasil pewarisan (&lt;em style=&quot;box-sizing: border-box;&quot;&gt;prototype&lt;/em&gt;). Langsung saja, lihat contoh berikut:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;manusia&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;kepala&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;mata&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;telinga&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;tangan&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;kaki&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;jariTangan&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;jariKaki&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;namaProperti&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;namaProperti&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;manusia&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;namaProperti&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;: &quot;&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;manusia&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;namaProperti&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]);&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// Keluaran kode di atas:&lt;/span&gt;
&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// kepala: 1&lt;/span&gt;
&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// mata: 2&lt;/span&gt;
&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// telinga: 2&lt;/span&gt;
&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// tangan: 2&lt;/span&gt;
&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// kaki: 2&lt;/span&gt;
&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// jariTangan: 10&lt;/span&gt;
&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// jariKaki: 10&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Fitur ini seringkali berguna ketika kita ingin menggabungkan beberapa objek yang ada secara dinamis. Kegunaan lain lagi misalnya untuk memastikan sebuah properti ada di dalam objek. Kekurangan dari penelusuran seperti ini adalah jika kita menelusuri objek turunan,&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;for&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;in&lt;/span&gt;&lt;/code&gt;&amp;nbsp;akan melakukan penelusuran terhadap properti-properti milik objek induk juga. Misalnya pada kode di bawah:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;baju&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;jenis&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;Gaun&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;kain&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;Sutra&quot;&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;kemeja&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot; style=&quot;box-sizing: border-box; color: #007020;&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;baju&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;kemeja&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;jenis&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;Kemeja&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;kemeja&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;kerah&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;kemeja&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;: &quot;&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;kemeja&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]);&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// Keluaran kode di atas:&lt;/span&gt;
&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// jenis: Kemeja&lt;/span&gt;
&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// kerah: true&lt;/span&gt;
&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// kain: Sutra&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Dalam kode di atas, dapat dilihat bagaimana&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;jenis&lt;/span&gt;&lt;/code&gt;&amp;nbsp;dan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;kain&lt;/span&gt;&lt;/code&gt;&amp;nbsp;tetap ditelusuri oleh&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;for&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;in&lt;/span&gt;&lt;/code&gt;. Jika tidak ingin menelusuri nilai turunan, kita dapat menggunakan fungsi&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;hasOwnProperty&lt;/span&gt;&lt;/code&gt;:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;kemeja&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;kemeja&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;hasOwnProperty&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;: &quot;&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;kemeja&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]);&lt;/span&gt;
    &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// Keluaran kode di atas:&lt;/span&gt;
&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// jenis: Kemeja&lt;/span&gt;
&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// kerah: true&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Dengan melakukan validasi menggunakan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;hasOwnProperty&lt;/span&gt;&lt;/code&gt;&amp;nbsp;terlebih dahulu, kita dapat menghapus properti yang bukan asli milik objek. Perhatikan juga bagaimana&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;jenis&lt;/span&gt;&lt;/code&gt;&amp;nbsp;tetap ditelusuri. Hal ini terjadi karena&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;jenis&lt;/span&gt;&lt;/code&gt;&amp;nbsp;sudah kita isikan dengan nilai baru, sehingga&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;jenis&lt;/span&gt;&lt;/code&gt;&amp;nbsp;dianggap milik&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;kemeja&lt;/span&gt;&lt;/code&gt;.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Terakhir, jika ingin tidak menelusuri&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;method&lt;/em&gt;&amp;nbsp;(detil tentang&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;method&lt;/em&gt;&amp;nbsp;dapat dibaca pada bab selanjutnya), kita dapat menggunakan ekspresi&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;typeof&lt;/span&gt;&lt;/code&gt;&amp;nbsp;untuk mengecek apakah sebuah properti fungsi atau bukan:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;objek&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;prop1&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;testing&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;meth1&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// sebuah method&lt;/span&gt;
        &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;method&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;objek&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;: &quot;&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;objek&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]);&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// For di atas (yang tidak memiliki if) mencetak:&lt;/span&gt;
&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// prop1: testing&lt;/span&gt;
&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;//  meth1: function () { // sebuah method&lt;/span&gt;
&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;//      return &quot;method&quot;;&lt;/span&gt;
&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;//  }&lt;/span&gt;

&lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;objek&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;typeof&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;objek&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;!==&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;function&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;: &quot;&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;objek&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]);&lt;/span&gt;
    &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// For kedua (yang memiliki if) mencetak:&lt;/span&gt;
&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// prop1: testing&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Catatan lain yang juga perlu diingat adalah bahwa penelusuran properti dengan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;for&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;in&lt;/span&gt;&lt;/code&gt;&amp;nbsp;seperti ini tidak memperhatikan urutan penulisan properti pada objek. Meskipun terdapat beberapa cara untuk menghindari hal ini, kita lebih disarankan untuk tidak bergantung kepada urutan properti jika ingin melakukan penelusuran.&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;penanganan-nilai-global&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: &amp;quot;Open Sans&amp;quot;, Calibri, Candara, Arial, sans-serif; font-size: 15px; line-height: 21.4286px;&quot;&gt;
&lt;h2 style=&quot;box-sizing: border-box; color: inherit; font-size: 32px; font-weight: 300; line-height: 1.1; margin-bottom: 10.5px; margin-top: 21px;&quot;&gt;
Penanganan Nilai Global&lt;a class=&quot;headerlink&quot; href=&quot;https://bertzzie.com/knowledge/javascript/Objek-pada-Javascript.html#penanganan-nilai-global&quot; style=&quot;background: transparent; box-sizing: border-box; color: #007fff; text-decoration: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Pada bab sebelumnya kita telah membahas bahwa salah satu kesalahan desain yang paling fatal dari Javascript adalah penggunaan nilai global secara standar. Di bagian ini kita akan mencoba sedikit memperbaiki hal ini, dengan menggunakan objek.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Penanganan kita lakukan dengan membuat sebuah objek global yang menampung seluruh kode kita. Objek global ini merupakan objek yang pertama kali kita buat sebelum aplikasi dijalankan. Objek harus dibuat&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;sebelum&lt;/strong&gt;&amp;nbsp;kode lain berjalan. Berikut adalah implementasi paling sederhana dari objek global kita:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;MYAPP&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;MYAPP&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{};&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Kode yang sangat sederhana. Kita hanya mendeklarasikan sekaligsu memanggil objek global kita,&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;MYAPP&lt;/span&gt;&lt;/code&gt;, jika&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;MYAPP&lt;/span&gt;&lt;/code&gt;&amp;nbsp;telah dideklarasikan sebelumnya. Jika belum dideklarasikan, kita akan membuat sebuah objek kosong. Selanjutnya kita dapat mengisikan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;MYAPP&lt;/span&gt;&lt;/code&gt;&amp;nbsp;dengan kode yang kita inginkan:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2
3
4
5
6&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;MYAPP&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;mobil&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;Mobil&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;jumlahBan&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;4&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;MYAPP&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;truk&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot; style=&quot;box-sizing: border-box; color: #007020;&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;MYAPP&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;mobil&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;);&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Dengan menggunakan cara penulisan kode seperti di atas, kita akan mengurangi variabel yang ada pada skala global menjadi hanya satu variabel saja, yaitu&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;MYAPP&lt;/span&gt;&lt;/code&gt;. Selain mengurangi sifat global dari aplikasi kita, dengan membuat objek global seperti ini kita juga secara otomatis mempermudah interaksi dengan&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;library&lt;/em&gt;&amp;nbsp;lain seperti jQuery atau Yui. Keuntungan lainnya adalah kemudahan pembacaan kode, karena kita akan dengan mudah mengetahui mana objek buatan kita dan mana objek buatan&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;library&lt;/em&gt;&amp;nbsp;lain. Hal ini juga lah yang menjadi alasan kenapa&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;library&lt;/em&gt;&amp;nbsp;javascript umumnya memiliki simbol khusus untuk pemanggilannya, misalnya&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;$&lt;/span&gt;&lt;/code&gt;&amp;nbsp;pada jQuery atau&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;YUI()&lt;/span&gt;&lt;/code&gt;&amp;nbsp;pada YUI.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Pada bab berikutnya dan bab selanjutnya kita juga akan menambahkan fungsionalitas pada fungsi global ini, sehingga kita bisa memiliki fitur-fitur tambahan yang kerap ada pada bahasa OOP modern seperti&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;namespace&lt;/em&gt;.&lt;br /&gt;
&lt;br /&gt;
from:https://bertzzie.com/knowledge/javascript/Objek-pada-Javascript.html&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://armoe.blogspot.com/feeds/8471960429567777942/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='http://armoe.blogspot.com/2016/06/objek-pada-javascript.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/8471960429567777942'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/8471960429567777942'/><link rel='alternate' type='text/html' href='http://armoe.blogspot.com/2016/06/objek-pada-javascript.html' title='Objek pada Javascript'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02277756216508959449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2065822655831694480.post-6631178944373864321</id><published>2016-06-17T16:00:00.001-07:00</published><updated>2016-06-17T16:00:26.726-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="Tutorial Bhs Indo"/><title type='text'>Pengenalan Javascript</title><content type='html'>&lt;h1 style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: &amp;quot;Open Sans&amp;quot;, Calibri, Candara, Arial, sans-serif; font-size: 39px; font-weight: 300; line-height: 1.1; margin: 21px 0px 10.5px;&quot;&gt;
&lt;span style=&quot;font-size: 15px; line-height: 21.4286px;&quot;&gt;Pada bagian ini kita akan membahas sekilas dasar-dasar pemrograman Javascript untuk menyegarkan pikiran pembaca mengenai fitur umum Javascript. Kita tidak akan melihat masing-masing fitur secara terperinci, karena telah terdapat banyak pustaka yang membahas dasar pemrograman Javascript secara terperinci. Karena dirancang sebagai penyegaran saja, maka pembaca diharapkan telah memiliki pengalaman dalam pemrograman secara umum, dan mengerti perintah-perintah dasar pemrograman seperti perulangan dan percabangan.&lt;/span&gt;&lt;/h1&gt;
&lt;div class=&quot;section&quot; id=&quot;menggunakan-javascript&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: &amp;quot;Open Sans&amp;quot;, Calibri, Candara, Arial, sans-serif; font-size: 15px; line-height: 21.4286px;&quot;&gt;
&lt;h2 style=&quot;box-sizing: border-box; color: inherit; font-size: 32px; font-weight: 300; line-height: 1.1; margin-bottom: 10.5px; margin-top: 21px;&quot;&gt;
Menggunakan Javascript&lt;a class=&quot;headerlink&quot; href=&quot;https://bertzzie.com/knowledge/javascript/Pengenalan-Ulang-Javascript.html#menggunakan-javascript&quot; style=&quot;background: transparent; box-sizing: border-box; color: #007fff; text-decoration: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Javascript merupakan bahasa yang dirancang untuk digunakan bersamaan dengan halaman web. Karena hal ini maka secara otoamtis kita akan memerlukan&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;browser&lt;/em&gt;&amp;nbsp;dan dokumen HTML untuk menjalankan Javascript. Umumnya, kita akan memerlukan sebuah dokumen HTML dan satu berkas Javascript untuk menjalankan kode yang ada dalam buku ini. Mengikuti konvensi umum dalam dunia web, dokumen HTML yang kita gunakan akan diberi nama&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;index.html&lt;/span&gt;&lt;/code&gt;, sementara berkas javascript diberi nama&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;script.js&lt;/span&gt;&lt;/code&gt;.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Adapun isi dari&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;index.html&lt;/span&gt;&lt;/code&gt;&amp;nbsp;adalah sebagai berikut:&lt;/div&gt;
&lt;div class=&quot;highlight-html&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;cp&quot; style=&quot;box-sizing: border-box; color: #007020;&quot;&gt;&amp;lt;!DOCTYPE HTML&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot; style=&quot;box-sizing: border-box; color: #062873; font-weight: bold;&quot;&gt;&amp;lt;html&lt;/span&gt; &lt;span class=&quot;na&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;lang=&lt;/span&gt;&lt;span class=&quot;s&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;en&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot; style=&quot;box-sizing: border-box; color: #062873; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot; style=&quot;box-sizing: border-box; color: #062873; font-weight: bold;&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot; style=&quot;box-sizing: border-box; color: #062873; font-weight: bold;&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;charset=&lt;/span&gt;&lt;span class=&quot;s&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;UTF-8&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot; style=&quot;box-sizing: border-box; color: #062873; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot; style=&quot;box-sizing: border-box; color: #062873; font-weight: bold;&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Dokumen HTML&lt;span class=&quot;nt&quot; style=&quot;box-sizing: border-box; color: #062873; font-weight: bold;&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot; style=&quot;box-sizing: border-box; color: #062873; font-weight: bold;&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot; style=&quot;box-sizing: border-box; color: #062873; font-weight: bold;&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;nt&quot; style=&quot;box-sizing: border-box; color: #062873; font-weight: bold;&quot;&gt;&amp;lt;script &lt;/span&gt;&lt;span class=&quot;na&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;text/javascript&quot;&lt;/span&gt; &lt;span class=&quot;na&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;src=&lt;/span&gt;&lt;span class=&quot;s&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;script.js&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot; style=&quot;box-sizing: border-box; color: #062873; font-weight: bold;&quot;&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot; style=&quot;box-sizing: border-box; color: #062873; font-weight: bold;&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot; style=&quot;box-sizing: border-box; color: #062873; font-weight: bold;&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Sementara isi dari&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;script.js&lt;/span&gt;&lt;/code&gt;&amp;nbsp;akan selalu berbeda, tergantung dari pembahasan kita.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Pada perkembangannya, Javascript juga dapat digunakan untuk pengembangan perangakat lunak umum tanpa memerlukan&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;browser&lt;/em&gt;. Jika tertarik, anda juga dapat menggunakan Javascript melalui cara ini, misalnya jalankan kode yang ada pada contoh melalui&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;NodeJS&lt;/span&gt;&lt;/code&gt;. Detil dari perangkat lunak pengembangan Javascript modern seperti ini dapat dibaca pada bagian “Perangkat Pengembangan Javascript Modern”.&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;tipe-data-dasar&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: &amp;quot;Open Sans&amp;quot;, Calibri, Candara, Arial, sans-serif; font-size: 15px; line-height: 21.4286px;&quot;&gt;
&lt;h2 style=&quot;box-sizing: border-box; color: inherit; font-size: 32px; font-weight: 300; line-height: 1.1; margin-bottom: 10.5px; margin-top: 21px;&quot;&gt;
Tipe Data Dasar&lt;a class=&quot;headerlink&quot; href=&quot;https://bertzzie.com/knowledge/javascript/Pengenalan-Ulang-Javascript.html#tipe-data-dasar&quot; style=&quot;background: transparent; box-sizing: border-box; color: #007fff; text-decoration: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Seperti kebanyakan bahasa pemrograman lainnya, Javascript memiliki beberapa tipe data untuk dimanipulasi. Seluruh nilai yang ada dalam Javascript selalu memiliki tipe data. Tipe data yang dimiliki oleh Javascript adalah sebagai berikut:&lt;/div&gt;
&lt;ul style=&quot;box-sizing: border-box; margin-bottom: 10.5px; margin-top: 0px;&quot;&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;&lt;div class=&quot;first&quot; style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Number (bilangan)&lt;/div&gt;
&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;&lt;div class=&quot;first&quot; style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
String (serangkaian karakter)&lt;/div&gt;
&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;&lt;div class=&quot;first&quot; style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Boolean (benar / salah)&lt;/div&gt;
&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;
&lt;dl class=&quot;first docutils&quot; style=&quot;box-sizing: border-box; margin-bottom: 21px; margin-top: 0px !important;&quot;&gt;
&lt;dt style=&quot;box-sizing: border-box; font-weight: bold; line-height: 1.42857;&quot;&gt;Object&lt;/dt&gt;
&lt;dd style=&quot;box-sizing: border-box; line-height: 1.42857; margin-bottom: 10px; margin-left: 0px; margin-top: 3px;&quot;&gt;&lt;ul class=&quot;first last simple&quot; style=&quot;box-sizing: border-box; margin-bottom: 0px; margin-top: 0px !important;&quot;&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Function (fungsi)&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Array&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Date&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;RegExp (&lt;em style=&quot;box-sizing: border-box;&quot;&gt;regular expression&lt;/em&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;&lt;/dl&gt;
&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;&lt;div class=&quot;first&quot; style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Null (tidak berlaku / kosong)&lt;/div&gt;
&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;&lt;div class=&quot;first&quot; style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Undefined (tidak didefinisikan)&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Kebanyakan dari tipe data yang disebutkan di atas sama seperti tipe data sejenis pada bahasa pemrograman lainnya. Misalnya, sebuah&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;boolean&lt;/span&gt;&lt;/code&gt;&amp;nbsp;terdiri dari dua nilai saja, yaitu&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;true&lt;/span&gt;&lt;/code&gt;&amp;nbsp;dan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;false&lt;/span&gt;&lt;/code&gt;. Untuk mempersingkat pembahasan, kita hanya akan melihat beberapa tipe data yang menarik dari Javascript pada bagian ini, yaitu&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;Number&lt;/span&gt;&lt;/code&gt;,&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;String&lt;/span&gt;&lt;/code&gt;, dan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;Array&lt;/span&gt;&lt;/code&gt;.&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;Number&lt;/span&gt;&lt;/code&gt;&amp;nbsp;dan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;String&lt;/span&gt;&lt;/code&gt;&amp;nbsp;akan dibahas langsung pada bagian ini, sementara&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;Array&lt;/span&gt;&lt;/code&gt;&amp;nbsp;akan dibahas setelah pembahasan variabel, karena array tidak akan terlalu berguna tanpa digunakan dengan variabel.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Tipe data lainnya, seperti&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;Function&lt;/span&gt;&lt;/code&gt;&amp;nbsp;dan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;Object&lt;/span&gt;&lt;/code&gt;&amp;nbsp;akan dibahas secara sangat detail dan mendalam pada bab-bab selanjutnya, sementara nilai lainnya tidak akan dibahas secara mendalam.&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;number-bilangan&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;h3 style=&quot;box-sizing: border-box; color: inherit; font-size: 26px; font-weight: 300; line-height: 1.1; margin-bottom: 10.5px; margin-top: 21px;&quot;&gt;
Number (Bilangan)&lt;a class=&quot;headerlink&quot; href=&quot;https://bertzzie.com/knowledge/javascript/Pengenalan-Ulang-Javascript.html#number-bilangan&quot; style=&quot;background: transparent; box-sizing: border-box; color: #007fff; text-decoration: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Seluruh bilangan yang ada pada Javascript merupakan nilai&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;double&lt;/em&gt;, tepatnya “Double-Precision 64-bit Format IEEE 754 Values” sesuai dengan yang tertulis dalam spesifikasi bahasa Javascript. Sederhananya, Javascript hanya mengenal bilangan pecahan.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Penggunaan&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;double&lt;/em&gt;&amp;nbsp;sebagai nilai dasar menjadikan data bilangan pada Javascript sangat menarik. Misalnya, Javascript tidak memiliki&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;integer&lt;/em&gt;&amp;nbsp;atau bilangan bulat. Hal ini berarti kita harus sangat berhati-hati dalam melakukan perhitungan aritmatis, misalnya untuk kode-kode seperti berikut:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;mf&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;0.1&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mf&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;0.2&lt;/span&gt; &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// menghasilkan 0.30000000000000004&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Pada prakteknya, bilangan bulat biasanya disimpan dan diperlakukan sebagai integer 32-bit. Hal ini dilakukan untuk mempermudah pengembang aplikasi dalam melakukan operasi-operasi umum terhadap&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;integer&lt;/em&gt;, misalnya pergeseran bit.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Operator numerik umum untuk operasi aritmatika juga pastinya didukung oleh Javascript. Operator-operator dasar seperti&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;+&lt;/span&gt;&lt;/code&gt;,&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;*&lt;/span&gt;&lt;/code&gt;,&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;-&lt;/span&gt;&lt;/code&gt;,&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;/&lt;/span&gt;&lt;/code&gt;, dan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;%&lt;/span&gt;&lt;/code&gt;&amp;nbsp;cara kerjanya sama dengan bahasa lain:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2
3
4
5&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;10&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;20&lt;/span&gt; &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// menghasilkan 30&lt;/span&gt;
&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;10&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;5&lt;/span&gt;  &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// menghasilkan 5&lt;/span&gt;
&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;5&lt;/span&gt;  &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;15&lt;/span&gt; &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// menghasilkan 75&lt;/span&gt;
&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;15&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;5&lt;/span&gt;  &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// menghasilkan 3&lt;/span&gt;
&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;13&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;2&lt;/span&gt;  &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// menghasilkan 1&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Untuk operasi aritmatika yang lebih kompleks, Javascript menyediakan objek&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;Math&lt;/span&gt;&lt;/code&gt;:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;nb&quot; style=&quot;box-sizing: border-box; color: #007020;&quot;&gt;Math&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;sin&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mf&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;3.5&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// menghasilkan -0.35078322768961984&lt;/span&gt;
&lt;span class=&quot;nb&quot; style=&quot;box-sizing: border-box; color: #007020;&quot;&gt;Math&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;pow&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// menghasilkan 8 (2 ^ 3)&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Kita juga dapat mengubah nilai string menjadi&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;integer&lt;/em&gt;&amp;nbsp;dengan menggunakan fungsi&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;parseInt&lt;/span&gt;&lt;/code&gt;. Fungsi&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;parseInt&lt;/span&gt;&lt;/code&gt;menerima dua argumen, dengan argumen pertama berupa string yang akan diubah, dan argumen kedua merupakan radiks (basis) dari nilai yang diberikan oleh parameter pertama. Contoh penggunaan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;parseInt&lt;/span&gt;&lt;/code&gt;&amp;nbsp;adalah seperti berikut:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2
3
4
5
6&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;nb&quot; style=&quot;box-sizing: border-box; color: #007020;&quot;&gt;parseInt&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;123&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// menghasilkan 123&lt;/span&gt;

&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// Menghasilkan 255&lt;/span&gt;
&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// &quot;100&quot; dianggap sebagai basis 16 karena parameter kedua,&lt;/span&gt;
&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// dan nilai basis 10 dari 100 pada basis 16 adalah 255.&lt;/span&gt;
&lt;span class=&quot;nb&quot; style=&quot;box-sizing: border-box; color: #007020;&quot;&gt;parseInt&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;100&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;);&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Parameter kedua dari fungsi&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;parseInt&lt;/span&gt;&lt;/code&gt;&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;harus selalu diisikan&lt;/strong&gt;&amp;nbsp;karena setiap&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;browser&lt;/em&gt;&amp;nbsp;akan mengimplementasikan parameter standar dengan nilai yang berbeda-beda. Akan lebih aman (dan jelas) jika kita selalu mengisikan parameter kekdua dari fungsi ini.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Selain fungsi&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;parseInt&lt;/span&gt;&lt;/code&gt;, Javascript juga memiliki fungsi&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;parseFloat&lt;/span&gt;&lt;/code&gt;, yang melakukan hal yang sama dengan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;parseInt&lt;/span&gt;&lt;/code&gt;, tetapi menghasilkan nilai pecahan (&lt;em style=&quot;box-sizing: border-box;&quot;&gt;float&lt;/em&gt;). Perbedaan lainnya adalah bahwa&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;parseFloat&lt;/span&gt;&lt;/code&gt;&amp;nbsp;akan selalu menghasilkan bilangan basis 10.&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;nb&quot; style=&quot;box-sizing: border-box; color: #007020;&quot;&gt;parseFloat&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;2.5323&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// menghasilkan 2.5323&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Selain bilangan&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;double&lt;/em&gt;, Javascript juga memiliki dua buah bilangan khusus, yaitu&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;NaN&lt;/span&gt;&lt;/code&gt;&amp;nbsp;dan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;Infinity&lt;/span&gt;&lt;/code&gt;.&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;NaN&lt;/span&gt;&lt;/code&gt;&amp;nbsp;merupakan singkatan dari “Not a Number” yang artinya bukan bilangan.&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;NaN&lt;/span&gt;&lt;/code&gt;&amp;nbsp;dapat dihasilkan jika terdapat perhitungan atau konversi bilangan yang tidak valid, misalnya jika kita mencoba mencari akar bilangan negatif atau mengisikan string teks ke&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;parseInt&lt;/span&gt;&lt;/code&gt;:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;nb&quot; style=&quot;box-sizing: border-box; color: #007020;&quot;&gt;Math&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;sqrt&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;);&lt;/span&gt;   &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// menghasilkan NaN&lt;/span&gt;
&lt;span class=&quot;nb&quot; style=&quot;box-sizing: border-box; color: #007020;&quot;&gt;parseInt&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;abc&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// menghasilkan NaN&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Bilangan khusus lainnya, yaitu&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;Infinity&lt;/span&gt;&lt;/code&gt;, yang berarti “tidak terbatas” dihasilkan ketika kita melakukan operasi yang menghasilkan bilangan tak terhingga pada matematika. Salah satu contoh dari operasi ini yaitu membagikan bilangan dengan 0:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;10&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// menghasilkan Infinity&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Untuk membantu kita dalam memastikan bilangan tidak memiliki nilai&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;NaN&lt;/span&gt;&lt;/code&gt;&amp;nbsp;atau&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;Infinity&lt;/span&gt;&lt;/code&gt;, Javascript menyediakan fungsi&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;isNaN&lt;/span&gt;&lt;/code&gt;&amp;nbsp;dan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;isFinite&lt;/span&gt;&lt;/code&gt;&amp;nbsp;kepada kita. Penggunaan masing-masing fungsi sendiri cukup jelas, sesuai dengan namanya:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2
3
4
5
6
7&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;nb&quot; style=&quot;box-sizing: border-box; color: #007020;&quot;&gt;isNaN&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kc&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;NaN&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;);&lt;/span&gt;           &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// menghasilkan true&lt;/span&gt;
&lt;span class=&quot;nb&quot; style=&quot;box-sizing: border-box; color: #007020;&quot;&gt;isNaN&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot; style=&quot;box-sizing: border-box; color: #007020;&quot;&gt;Math&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;sqrt&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;));&lt;/span&gt; &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// menghasilkan true&lt;/span&gt;
&lt;span class=&quot;nb&quot; style=&quot;box-sizing: border-box; color: #007020;&quot;&gt;isNaN&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;);&lt;/span&gt;            &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// menghasilkan false&lt;/span&gt;

&lt;span class=&quot;nb&quot; style=&quot;box-sizing: border-box; color: #007020;&quot;&gt;isFinite&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;);&lt;/span&gt;       &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// menghasilkan true&lt;/span&gt;
&lt;span class=&quot;nb&quot; style=&quot;box-sizing: border-box; color: #007020;&quot;&gt;isFinite&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;10&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;);&lt;/span&gt;   &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// menghasilkan false&lt;/span&gt;
&lt;span class=&quot;nb&quot; style=&quot;box-sizing: border-box; color: #007020;&quot;&gt;isFinite&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kc&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;Infinity&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// menghasilkan false&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;string&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;h3 style=&quot;box-sizing: border-box; color: inherit; font-size: 26px; font-weight: 300; line-height: 1.1; margin-bottom: 10.5px; margin-top: 21px;&quot;&gt;
String&lt;a class=&quot;headerlink&quot; href=&quot;https://bertzzie.com/knowledge/javascript/Pengenalan-Ulang-Javascript.html#string&quot; style=&quot;background: transparent; box-sizing: border-box; color: #007fff; text-decoration: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Sebuah string pada Javascript secara definisi sama dengan bahasa lain pada umumnya, yaitu kumpulan karakter. Satu hal yang menarik adalah bahwa string pada Javascript direpresentasikan dalam format Unicode 16-bit, yang artinya string Javascript mampu menampung karakter-karakter khusus seperti huruf Kanji Jepang atau teks berbahasa Arab. Format penyimpanan string ini tentunya sangat memudahkan kita ketika bekerja dengan aplikasi multi-bahasa.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Sebuah string ditandai oleh tanda petik, baik petik tunggal (&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;&#39;&lt;/span&gt;&lt;/code&gt;) ataupun petik ganda (&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;&quot;&lt;/span&gt;&lt;/code&gt;).&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2
3&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;Ini adalah sebuah string.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;s1&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&#39;ini juga wtring&#39;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;世界，你好！&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// sebuah string: &quot;Halo, dunia!&quot;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Contoh string yang kita jalankan pada kode di atas adalah string&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;primitive&lt;/em&gt;&amp;nbsp;yang dianggap sebagai tipe data dasar. Selain sebagai&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;primitive&lt;/em&gt;&amp;nbsp;Javascript juga memiliki string yang dianggap sebagai objek. Untungnya, karena fitur&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;http://stackoverflow.com/questions/17256182/javascript-string-literal-vs-string-object&quot; style=&quot;background: transparent; box-sizing: border-box; color: #007fff; text-decoration: none;&quot;&gt;autoboxing&lt;/a&gt;Javascript kita tidak melihat perbedaan fungsionalitas antara string&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;primitive&lt;/em&gt;&amp;nbsp;dan objek. Karena hal ini string&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;primitive&lt;/em&gt;maupun objek pada Javascript juga memiliki&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;method&lt;/em&gt;&amp;nbsp;dan properti tersendiri, layaknya bahasa pemrograman berorientasi objek lainnya, .&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2
3&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;Panjang&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;       &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// mengembalikan 7&lt;/span&gt;
&lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;Panjang&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;substring&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// mengembalikan &quot;jang&quot;&lt;/span&gt;
&lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;halo&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;toUpperCase&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;();&lt;/span&gt;   &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// mengembalikan &quot;HALO&quot;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Secara umum, penggunaan string pada Javascript tidak terlalu berbeda dengan string pada bahasa pemrograman lainnya. Yang selalu perlu diingat hanyalah bahwa string dalam Javascript mendukung Unicode 16-bit secara otomatis.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;variabel&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: &amp;quot;Open Sans&amp;quot;, Calibri, Candara, Arial, sans-serif; font-size: 15px; line-height: 21.4286px;&quot;&gt;
&lt;h2 style=&quot;box-sizing: border-box; color: inherit; font-size: 32px; font-weight: 300; line-height: 1.1; margin-bottom: 10.5px; margin-top: 21px;&quot;&gt;
Variabel&lt;a class=&quot;headerlink&quot; href=&quot;https://bertzzie.com/knowledge/javascript/Pengenalan-Ulang-Javascript.html#variabel&quot; style=&quot;background: transparent; box-sizing: border-box; color: #007fff; text-decoration: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Seperti pada bahasa pemrograman lainnya, variabel dalam Javascript merupakan sebuah tempat untuk menyimpan data sementara. Variabel dibuat dengan kata kunci&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;var&lt;/span&gt;&lt;/code&gt;&amp;nbsp;pada Javascript.&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;             &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// a berisi undefined&lt;/span&gt;
&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;Budi&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// nama berisi &quot;Budi&quot;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Seperti yang dapat dilihat pada contoh di atas, ketika kita tidak mengisikan nilai apa-apa ke dalam variabel pada saat pembuatan, maka variabel tersebut berisi nilai&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;undefined&lt;/span&gt;&lt;/code&gt;. Jika nilai variabel diambil dari sumber luar (misalnya pemanggilan fungsi), kita dapat menggunakan operator&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;||&lt;/span&gt;&lt;/code&gt;&amp;nbsp;untuk memberikan nilai standar (&lt;em style=&quot;box-sizing: border-box;&quot;&gt;default&lt;/em&gt;) untuk menanggulangi kasus di mana fungsi tidak mengembalikan apa-apa:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;dataRahasia&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;AmbilDataRahasia&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;Data Kosong&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Pada contoh kode di atas,&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;dataRahasia&lt;/span&gt;&lt;/code&gt;&amp;nbsp;akan berisi&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;&quot;Data&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;Kosong&quot;&lt;/span&gt;&lt;/code&gt;&amp;nbsp;ketika&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;AmbilDataRahasia()&lt;/span&gt;&lt;/code&gt;&amp;nbsp;tidak mengembalikan apa-apa (misalnya karena tidak ada data rahasia, atau fungsi&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;error&lt;/em&gt;).&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Nilai yang ada di dalam variabel dapat diganti dengan mengisikan nilai baru, dan bahkan dapat diganti tipe datanya juga.&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;Anton&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// nama sekarang berisi string  &quot;Anton&quot;&lt;/span&gt;
&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;nama&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;       &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// nama sekarang berisi integer 1&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Walaupun kemampuan untuk menggantikan tipe data ini sangat memudahkan kita dalam mengembangkan aplikasi, fitur ini harus digunakan dengan sangat hati-hati. Perubahan tipe data yang tidak diperkirakan dengan baik dapat menyebabkan berbagai kesalahan (&lt;em style=&quot;box-sizing: border-box;&quot;&gt;error&lt;/em&gt;) pada program, misalnya jika kita mencoba mengakses&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;method&lt;/em&gt;&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;charAt&lt;/span&gt;&lt;/code&gt;&amp;nbsp;setelah mengubah tipe pada contoh di atas.&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;array&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: &amp;quot;Open Sans&amp;quot;, Calibri, Candara, Arial, sans-serif; font-size: 15px; line-height: 21.4286px;&quot;&gt;
&lt;h2 style=&quot;box-sizing: border-box; color: inherit; font-size: 32px; font-weight: 300; line-height: 1.1; margin-bottom: 10.5px; margin-top: 21px;&quot;&gt;
Array&lt;a class=&quot;headerlink&quot; href=&quot;https://bertzzie.com/knowledge/javascript/Pengenalan-Ulang-Javascript.html#array&quot; style=&quot;background: transparent; box-sizing: border-box; color: #007fff; text-decoration: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Array merupakan sebuah tipe data yang digunakan untuk menampung banyak tipe data lainnya. Berbeda dengan tipe data&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;object&lt;/span&gt;&lt;/code&gt;, array pada Javascript merupakan sebuah tipe khusus. Walaupun memiliki&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;method&lt;/em&gt;&amp;nbsp;dan properti, array bukanlah objek, melainkan sebuah tipe yang “mirip objek”. Untungnya, pada kebanyakan kasus, kita dapat memperlakukan array layaknya sebuah objek.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Pembuatan array dalam Javascript dilakukan dengan menggunakan kurung siku (&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;[]&lt;/span&gt;&lt;/code&gt;):&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;satu&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;dua&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;tiga&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;];&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
elemen-elemen dalam array sendiri tidak harus memiliki tipe data yang sama:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;dataAcak&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;satu&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kc&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;];&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
dan tentunya kita boleh membuat array di dalam array (lebih dikenal dengan istilah “array dua dimensi”):&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;arr2&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[[&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;satu&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;dua&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;tiga&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;empat&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]];&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Akses elemen dalam array dilakukan dengan menggunakan kurung siku juga. Nilai yang kita berikan dalam kurung siku adalah urutan elemen penulisan array (indeks), yang dimulai dari nilai 0. Jika indeks yang diakses tidak ada, maka kita akan mendapatkan nilai&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;undefined&lt;/span&gt;&lt;/code&gt;.&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2
3
4
5&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;];&lt;/span&gt;     &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// mengembalikan &quot;tiga&quot;&lt;/span&gt;
&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;dataAcak&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;];&lt;/span&gt; &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// mengembalikan 2&lt;/span&gt;
&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;arr2&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;];&lt;/span&gt;  &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// mengembalikan &quot;dua&quot;&lt;/span&gt;

&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;];&lt;/span&gt;    &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// mengembalikan undefined&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Sebagai sebuah objek khusus, array juga memiliki&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;method&lt;/em&gt;&amp;nbsp;dan properti. Beberapa&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;method&lt;/em&gt;&amp;nbsp;dan properti yang populer misalnya&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;length&lt;/span&gt;&lt;/code&gt;,&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;pop()&lt;/span&gt;&lt;/code&gt;, dan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;push()&lt;/span&gt;&lt;/code&gt;. Kegunaan dari masing-masing&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;method&lt;/em&gt;&amp;nbsp;maupun properti tersebut dapat ditebak dari namanya.&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2
3
4
5
6&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;a&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;b&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;c&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;];&lt;/span&gt;

&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;    &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// mengembalikan 3&lt;/span&gt;

&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;d&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// mengembalikan   4, data menjadi [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;]&lt;/span&gt;
&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;pop&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;();&lt;/span&gt;     &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// mengembalikan &quot;d&quot;, data menjadi [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;pengendalian-struktur&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: &amp;quot;Open Sans&amp;quot;, Calibri, Candara, Arial, sans-serif; font-size: 15px; line-height: 21.4286px;&quot;&gt;
&lt;h2 style=&quot;box-sizing: border-box; color: inherit; font-size: 32px; font-weight: 300; line-height: 1.1; margin-bottom: 10.5px; margin-top: 21px;&quot;&gt;
Pengendalian Struktur&lt;a class=&quot;headerlink&quot; href=&quot;https://bertzzie.com/knowledge/javascript/Pengenalan-Ulang-Javascript.html#pengendalian-struktur&quot; style=&quot;background: transparent; box-sizing: border-box; color: #007fff; text-decoration: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Javascript memiliki perintah-perintah pengendalian struktur (&lt;em style=&quot;box-sizing: border-box;&quot;&gt;control stucture&lt;/em&gt;) yang sama dengan bahasa dalam keluarga C. Perintah&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;if&lt;/span&gt;&lt;/code&gt;&amp;nbsp;dan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;else&lt;/span&gt;&lt;/code&gt;&amp;nbsp;digunakan untuk percabangan, sementara perintah&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;for&lt;/span&gt;&lt;/code&gt;,&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;for-in&lt;/span&gt;&lt;/code&gt;,&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;while&lt;/span&gt;&lt;/code&gt;, dan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;do-while&lt;/span&gt;&lt;/code&gt;digunakan untuk perulangan.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Percabangan bisa dikatakan sama persis dengan C atau Java:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;gelar&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;pendidikan&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;S2&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;pendidikan&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;S1&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;gelar&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;Sarjana&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;pendidikan&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;S2&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;gelar&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;Master&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;pendidikan&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;S3&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;gelar&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;Doktor&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;gelar&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #4070a0;&quot;&gt;&quot;Tidak Diketahui&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;gelar&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// gelar berisi &quot;Master&quot;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Satu hal yang perlu diperhatikan adalah bahwa kita menggunakan tiga buah sama dengan (&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;===&lt;/span&gt;&lt;/code&gt;) pada operasi perbandingan. Javascript mendukung dua operator perbandingan sama dengan, yaitu&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;==&lt;/span&gt;&lt;/code&gt;&amp;nbsp;dan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;===&lt;/span&gt;&lt;/code&gt;. Perbedaan utamanya adalah&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;==&lt;/span&gt;&lt;/code&gt;&amp;nbsp;mengubah tipe data yang dicek menjadi nilai terdekat, sementara&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;===&lt;/span&gt;&lt;/code&gt;&amp;nbsp;memastikan tipe data dari dua nilai yang dibandingkan sama. Untuk mendapatkan nilai perbandingan paling akurat, selalu gunakan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;===&lt;/span&gt;&lt;/code&gt;&amp;nbsp;ketika mengecek nilai.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Sama seperti&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;if&lt;/span&gt;&lt;/code&gt;, perulangan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;do&lt;/span&gt;&lt;/code&gt;,&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;do-while&lt;/span&gt;&lt;/code&gt;, dan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;for&lt;/span&gt;&lt;/code&gt;&amp;nbsp;memiliki cara pemakaian yang dapat dikatakan sama persis dengan C atau Java:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kc&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// tak pernah berhenti&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;input&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;get_input&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;inputIsNotValid&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;))&lt;/span&gt;

&lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// berulang sebanyak 5 kali&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Perulangan&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;for-in&lt;/span&gt;&lt;/code&gt;&amp;nbsp;memiliki dua buah kegunaan utama. Kegunaan yang pertama adalah untuk menelusuri nilai dalam array seperti pada Java:&lt;/div&gt;
&lt;div class=&quot;highlight-javascript&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;table class=&quot;highlighttable&quot; style=&quot;background-color: transparent; border-collapse: collapse; border-spacing: 0px; border: 0px; box-sizing: border-box; margin: 10px auto 10px 0.5em; max-width: 100%; width: 847px;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;
&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td class=&quot;linenos&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;linenodiv&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: transparent; border-radius: 0px; border: 0px; box-sizing: border-box; color: #aaaaaa; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 5px 0px; word-break: normal; word-wrap: break-word;&quot;&gt;1
2
3
4
5&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;box-sizing: border-box; padding: 0px 0.5em;&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;background: none; box-sizing: border-box;&quot;&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; color: #333333; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 1.42857; margin-bottom: 10.5px; overflow: auto; padding: 10px; word-break: break-all; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;kd&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #208050;&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;];&lt;/span&gt;
&lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;d&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: #007020; font-weight: bold;&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nx&quot; style=&quot;box-sizing: border-box;&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// d akan bernilai 1, 2, dan 3&lt;/span&gt;
    &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #408090; font-style: italic;&quot;&gt;// untuk masing-masing iterasi&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
Kegunaan kedua dari&amp;nbsp;&lt;code style=&quot;background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;for-in&lt;/span&gt;&lt;/code&gt;&amp;nbsp;adalah untuk menelusuri properti dalam objek. Kegunaan kedua ini akan dibahas secara mendetail pada bagian “Objek pada Javascript”&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10.5px;&quot;&gt;
from:https://bertzzie.com/knowledge/javascript/Pengenalan-Ulang-Javascript.html&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://armoe.blogspot.com/feeds/6631178944373864321/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='http://armoe.blogspot.com/2016/06/pengenalan-javascript.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/6631178944373864321'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/6631178944373864321'/><link rel='alternate' type='text/html' href='http://armoe.blogspot.com/2016/06/pengenalan-javascript.html' title='Pengenalan Javascript'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02277756216508959449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2065822655831694480.post-7591850227222769009</id><published>2016-06-17T15:56:00.001-07:00</published><updated>2016-06-17T15:56:57.437-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Sharp"/><category scheme="http://www.blogger.com/atom/ns#" term="English Tutorial"/><title type='text'>Associating Strings with enums</title><content type='html'>&lt;div style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Calibri Light&amp;quot;; font-size: 20pt; margin: 0in;&quot;&gt;
Associating
Strings with enums&lt;/div&gt;
&lt;div style=&quot;color: grey; font-family: Calibri; font-size: 10.0pt; margin: 0in;&quot;&gt;
Friday,
December 19, 2014&lt;/div&gt;
&lt;div style=&quot;color: grey; font-family: Calibri; font-size: 10.0pt; margin: 0in;&quot;&gt;
4:26 PM&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 11pt; margin: 0in;&quot;&gt;
I
have seen other great articles out lining the benefits of some pretty clever
and useful helper classes for enums. Many of these methods almost exactly
mirror methods I had written in my own EnumHelper class. (Isn&#39;t it crazy when
you imagine how much code duplication there must be like this out there!)&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 11pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 11pt; margin: 0in;&quot;&gt;
One
thing that I don&#39;t see emphasized much is trying to associated string values
with enums. For example, what if you want to have a Drop Down list that you can
choose from a list of values (which are backed by an enum)? Lets start with a
test enum:&lt;/div&gt;
&lt;div style=&quot;color: blue; font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;enum&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;States&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #666600; font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
{&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;California&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;NewMexico&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;NewYork&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;SouthCarolina&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;Tennessee&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;Washington&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #666600; font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
}&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 11pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 11pt; margin: 0in;&quot;&gt;
So
if you made a drop down list out of this enum, using the ToString() method, you
would get a drop down that looks like this:&lt;/div&gt;
&lt;div style=&quot;margin: 0in;&quot;&gt;
&lt;img alt=&quot;state drop down&quot; height=&quot;141&quot; src=&quot;file:///C:\Users\MYDEV_PC\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png&quot; width=&quot;117&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 11pt; margin: 0in;&quot;&gt;
While
most people will understand this, it should really be displayed like this:&lt;/div&gt;
&lt;div style=&quot;margin: 0in;&quot;&gt;
&lt;img alt=&quot;correct state drop down&quot; height=&quot;135&quot; src=&quot;file:///C:\Users\MYDEV_PC\AppData\Local\Temp\msohtmlclip1\01\clip_image002.png&quot; width=&quot;118&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 11pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 11pt; margin: 0in;&quot;&gt;
&quot;But
enums can&#39;t have spaces in C#!&quot; you say. Well, I like to use the
System.ComponentModel.DescriptionAttribute to add a more friendly description
to the enum values. The example enum can be rewritten like this:&lt;/div&gt;
&lt;div style=&quot;color: blue; font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;enum&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;States&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #666600; font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
{&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;California&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #666600;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Description&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;New Mexico&quot;&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;)]&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;NewMexico&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #666600;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Description&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;New York&quot;&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;)]&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;NewYork&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #666600;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Description&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;South Carolina&quot;&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;)]&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;SouthCarolina&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;Tennessee&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;Washington&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #666600; font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
}&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 11pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 11pt; margin: 0in;&quot;&gt;
Notice
that I do not put descriptions on items where the ToString() version of that
item displays just fine.&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 24pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 24pt; margin: 0in;&quot;&gt;
How
Do We Get To the Description?&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 11pt; margin: 0in;&quot;&gt;
Good
question! Well, using reflection of course! Here is what the code looks like:&lt;/div&gt;
&lt;div style=&quot;color: blue; font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;GetEnumDescription&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Enum&lt;/span&gt; value&lt;span style=&quot;color: #666600;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #666600; font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
{&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;FieldInfo&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;fi&lt;/span&gt; &lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt; value&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;GetType&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;().&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;GetField&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;value&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;ToString&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;());&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;DescriptionAttribute&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;[]&lt;/span&gt; attributes &lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt; &lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;DescriptionAttribute&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;[])&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;fi&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;GetCustomAttributes&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;typeof&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;DescriptionAttribute&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;),&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;attributes &lt;span style=&quot;color: #666600;&quot;&gt;!=&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;null&lt;/span&gt; &lt;span style=&quot;color: #666600;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; attributes&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Length&lt;/span&gt; &lt;span style=&quot;color: #666600;&quot;&gt;&amp;gt;&lt;/span&gt; 0&lt;span style=&quot;color: #666600;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; attributes&lt;span style=&quot;color: #666600;&quot;&gt;[&lt;/span&gt;0&lt;span style=&quot;color: #666600;&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Description&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; value&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;ToString&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;();&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #666600; font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
}&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 11pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;;&quot;&gt;This method first looks for the presence of a DescriptionAttribute
and if it doesn&#39;t find one, it just returns the ToString() of the value passed
in. So &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas;&quot;&gt;GetEnumDescription&lt;/span&gt;&lt;span style=&quot;color: #666600; font-family: Consolas;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas;&quot;&gt;States&lt;/span&gt;&lt;span style=&quot;color: #666600; font-family: Consolas;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas;&quot;&gt;NewMexico&lt;/span&gt;&lt;span style=&quot;color: #666600; font-family: Consolas;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #666600; font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 11pt; margin: 0in;&quot;&gt;
returns
the string &quot;New Mexico&quot;.&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 24pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 24pt; margin: 0in;&quot;&gt;
A
Free Bonus: How to Enumerate Enums&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 11pt; margin: 0in;&quot;&gt;
Ok,
so now we know how to get the string value of an enum. But as a free bonus, I
also have a helper method that allows you to enumerate all the values of a
given enum. This will allow you to easily create a drop down list based on an
enum. Here is the code for that method:&lt;/div&gt;
&lt;div style=&quot;color: blue; font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;IEnumerable&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;&amp;lt;&lt;/span&gt;T&lt;span style=&quot;color: #666600;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;EnumToList&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;&amp;lt;&lt;/span&gt;T&lt;span style=&quot;color: #666600;&quot;&gt;&amp;gt;()&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #666600; font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
{&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;Type&lt;/span&gt; enumType &lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;typeof&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;T&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008200;&quot;&gt;// Can&#39;t
use generic type constraints on value types,&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008200;&quot;&gt;// so have
to do check like this&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;enumType&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;BaseType&lt;/span&gt; &lt;span style=&quot;color: #666600;&quot;&gt;!=&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;typeof&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Enum&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;))&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;ArgumentException&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;T must be of
type System.Enum&quot;&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;Array&lt;/span&gt; enumValArray &lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;Enum&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;GetValues&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;enumType&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;List&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;&amp;lt;&lt;/span&gt;T&lt;span style=&quot;color: #666600;&quot;&gt;&amp;gt;&lt;/span&gt; enumValList &lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;List&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;&amp;lt;&lt;/span&gt;T&lt;span style=&quot;color: #666600;&quot;&gt;&amp;gt;(&lt;/span&gt;enumValArray&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Length&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;foreach&lt;/span&gt; &lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; val &lt;span style=&quot;color: blue;&quot;&gt;in&lt;/span&gt; enumValArray&lt;span style=&quot;color: #666600;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #666600;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; enumValList&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Add&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;((&lt;/span&gt;T&lt;span style=&quot;color: #666600;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Enum&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Parse&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;enumType&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt; val&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;ToString&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;()));&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #666600;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; enumValList&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #666600; font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
}&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 11pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 11pt; margin: 0in;&quot;&gt;
As
you can see, the code for either of these methods isn&#39;t too complicated. But
used in conjunction, they can be really useful. Here is an example of how we
would create the drop down list pictured above based on our enum:&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;color: #2b91af;&quot;&gt;DropDownList&lt;/span&gt;
stateDropDown &lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;DropDownList&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;();&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;foreach&lt;/span&gt; &lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;States&lt;/span&gt; state &lt;span style=&quot;color: blue;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;EnumToList&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;States&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;&amp;gt;())&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #666600; font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
{&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; stateDropDown&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Items&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Add&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;GetEnumDescription&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;state&lt;span style=&quot;color: #666600;&quot;&gt;));&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #666600; font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
}&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 11pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 24pt; margin: 0in;&quot;&gt;
One
More Example&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 11pt; margin: 0in;&quot;&gt;
There
is one more scenario that I often find myself needing to associate string
values with enums - when dealing with legacy constant string based system. Lets
say you have a library that has the following method:&lt;/div&gt;
&lt;div style=&quot;color: blue; font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;ExecuteAction&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; value&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; actionType&lt;span style=&quot;color: #666600;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #666600; font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
{&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;actionType &lt;span style=&quot;color: #666600;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;DELETE&quot;&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;Delete&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;();&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;actionType &lt;span style=&quot;color: #666600;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;UPDATE&quot;&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;Update&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;();&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #666600; font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
}&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 11pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 11pt; margin: 0in;&quot;&gt;
(I
tried to make this look as legacy as I could for a contrived example). What
happens if somebody passes in &quot;MyEvilAction&quot; as a value for
actionType? Well, whenever I see hard coded strings, that is a code smell that
could possibly point to the use of enums instead. &lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 11pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 11pt; margin: 0in;&quot;&gt;
But
sometimes you don&#39;t have control over legacy code and you have to deal with it.
So you could make an enum which looks like this:&lt;/div&gt;
&lt;div style=&quot;color: blue; font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;enum&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;ActionType&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #666600; font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
{&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #666600;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Description&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;DELETE&quot;&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;)]&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;Delete&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #666600;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Description&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;UPDATE&quot;&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;)]&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;Update&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #666600; font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
}&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 11pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 11pt; margin: 0in;&quot;&gt;
(I
know, I know, this is a very contrived example) Then you could call the
ExecuteAction Method like this:&lt;/div&gt;
&lt;div style=&quot;font-family: Consolas; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;color: #2b91af;&quot;&gt;ExecuteAction&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;5&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;GetEnumDescription&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;ActionType&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Delete&lt;/span&gt;&lt;span style=&quot;color: #666600;&quot;&gt;));&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 11pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 11pt; margin: 0in;&quot;&gt;
This
at least makes the code more readable and may also make it more consistent and
secure.&lt;/div&gt;
&lt;div style=&quot;font-family: &amp;quot;Segoe UI Light&amp;quot;; font-size: 11pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 9.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;color: #595959;&quot;&gt;From &amp;lt;&lt;/span&gt;&lt;a href=&quot;http://blog.spontaneouspublicity.com/associating-strings-with-enums-in-c&quot;&gt;http://blog.spontaneouspublicity.com/associating-strings-with-enums-in-c&lt;/a&gt;&lt;span style=&quot;color: #595959;&quot;&gt;&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://armoe.blogspot.com/feeds/7591850227222769009/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='http://armoe.blogspot.com/2016/06/associating-strings-with-enums.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/7591850227222769009'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/7591850227222769009'/><link rel='alternate' type='text/html' href='http://armoe.blogspot.com/2016/06/associating-strings-with-enums.html' title='Associating Strings with enums'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02277756216508959449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2065822655831694480.post-8388106460481499045</id><published>2016-06-17T15:55:00.000-07:00</published><updated>2016-06-17T15:55:30.615-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Sharp"/><category scheme="http://www.blogger.com/atom/ns#" term="English Tutorial"/><title type='text'>Pivot C# Array or DataTable: Convert a Column To a Row with LINQ</title><content type='html'>&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9ex23U5uFI_jN_8DcJpbuUC_DKjN_ClMTJyF_9fe9BmpdvPVPXJ69Obpo1hhHcBL81XPMnp4HvFGY_6j3INnO7JQcMLIro7T2nt0dmq7s1caUctqf4Fv_QBnau9jrBtQlwCx7JE1kWJIv/s1600/c-array-pivot.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;126&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9ex23U5uFI_jN_8DcJpbuUC_DKjN_ClMTJyF_9fe9BmpdvPVPXJ69Obpo1hhHcBL81XPMnp4HvFGY_6j3INnO7JQcMLIro7T2nt0dmq7s1caUctqf4Fv_QBnau9jrBtQlwCx7JE1kWJIv/s320/c-array-pivot.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 16.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;C# Array To Pivot DataTable:&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Here is the C# array
object:&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
?&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
var data = new[] { &lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;new
{ Product = &quot;Product 1&quot;, Year = 2009, Sales = 1212 },&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;new
{ Product = &quot;Product 2&quot;, Year = 2009, Sales = 522 },&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;new
{ Product = &quot;Product 1&quot;, Year = 2010, Sales = 1337 },&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;new
{ Product = &quot;Product 2&quot;, Year = 2011, Sales = 711 },&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;new
{ Product = &quot;Product 2&quot;, Year = 2012, Sales = 2245 },&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;new
{ Product = &quot;Product 3&quot;, Year = 2012, Sales = 1000 }&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;};&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
On Googling, I found
the following generic method in &lt;a href=&quot;http://stackoverflow.com/questions/17971921/how-to-convert-row-to-column-in-linq-and-sql&quot;&gt;StackOverflow
thread&lt;/a&gt;.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
?&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
public static
DataTable ToPivotTable&amp;lt;T, TColumn, TRow, TData&amp;gt;(&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this
IEnumerable&amp;lt;T&amp;gt; source,&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Func&amp;lt;T,
TColumn&amp;gt; columnSelector,&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Expression&amp;lt;Func&amp;lt;T,
TRow&amp;gt;&amp;gt; rowSelector,&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Func&amp;lt;IEnumerable&amp;lt;T&amp;gt;,
TData&amp;gt; dataSelector)&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DataTable
table = new DataTable();&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var
rowName = ((MemberExpression)rowSelector.Body).Member.Name;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;table.Columns.Add(new
DataColumn(rowName));&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var
columns = source.Select(columnSelector).Distinct();&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;foreach
(var column in columns)&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;table.Columns.Add(new
DataColumn(column.ToString()));&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var
rows = source.GroupBy(rowSelector.Compile())&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.Select(rowGroup
=&amp;gt; new&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Key
= rowGroup.Key,&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Values
= columns.GroupJoin(&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;rowGroup,&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;c
=&amp;gt; c,&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;r
=&amp;gt; columnSelector(r),&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(c,
columnGroup) =&amp;gt; dataSelector(columnGroup))&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;});&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;foreach
(var row in rows)&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var
dataRow = table.NewRow();&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var
items = row.Values.Cast&amp;lt;object&amp;gt;().ToList();&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;items.Insert(0,
row.Key);&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dataRow.ItemArray
= items.ToArray();&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;table.Rows.Add(dataRow);&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return
table;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
You can create a
static class for extension methods and put it there.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
To convert &lt;span style=&quot;font-weight: bold;&quot;&gt;Year&lt;/span&gt; values to columns and get Pivot DataTable:&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
?&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
var pivotTable =
data.ToPivotTable(&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;item
=&amp;gt; item.Year, &lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;item
=&amp;gt; item.Product,&amp;nbsp; &lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;items
=&amp;gt; items.Any() ? items.Sum(x=&amp;gt;x.Sales) : 0);&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
You will get the
following output:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEju_LzB0xCmHqwFNKFfSFUb38sVsbVpwSLqESDGbAntwalrTvn0_ggWkzzjUAJMXTDGTfKYSL9CFtYVy7bK6QU0Mn2x0xdxvEpE0wF42VJJ-p7ZDKVX-amWneendcyIpxKjQh-5tj7Edvsi/s1600/pivot-array-to-datatable.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;156&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEju_LzB0xCmHqwFNKFfSFUb38sVsbVpwSLqESDGbAntwalrTvn0_ggWkzzjUAJMXTDGTfKYSL9CFtYVy7bK6QU0Mn2x0xdxvEpE0wF42VJJ-p7ZDKVX-amWneendcyIpxKjQh-5tj7Edvsi/s320/pivot-array-to-datatable.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 16.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;C# Array to Pivot Dynamic Array:&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
You might want to
get the &lt;span style=&quot;font-weight: bold;&quot;&gt;List&amp;lt;dynamic&amp;gt;&lt;/span&gt; or &lt;span style=&quot;font-weight: bold;&quot;&gt;dynamic[]&lt;/span&gt; instead of getting DataTable after
converting columns to rows. It is handy in ASP.NET Web API to return JSON response.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
To do it, I updated
the extension method to get the dynamic object. use following extension method:&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
?&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public
static dynamic[] ToPivotArray&amp;lt;T, TColumn, TRow, TData&amp;gt;(&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
this
IEnumerable&amp;lt;T&amp;gt; source,&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Func&amp;lt;T,
TColumn&amp;gt; columnSelector,&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Expression&amp;lt;Func&amp;lt;T,
TRow&amp;gt;&amp;gt; rowSelector,&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Func&amp;lt;IEnumerable&amp;lt;T&amp;gt;,
TData&amp;gt; dataSelector)&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var
arr = new List&amp;lt;object&amp;gt;();&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var
cols = new List&amp;lt;string&amp;gt;();&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;String
rowName = ((MemberExpression)rowSelector.Body).Member.Name;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var
columns =
source.Select(columnSelector).Distinct();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cols
=(new []{ rowName}).Concat(columns.Select(x=&amp;gt;x.ToString())).ToList();&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var
rows = source.GroupBy(rowSelector.Compile())&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.Select(rowGroup
=&amp;gt; new&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Key
= rowGroup.Key,&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Values
= columns.GroupJoin(&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;rowGroup,&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;c
=&amp;gt; c,&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;r
=&amp;gt; columnSelector(r),&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(c,
columnGroup) =&amp;gt; dataSelector(columnGroup))&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}).ToArray();&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;foreach
(var row in rows)&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var
items = row.Values.Cast&amp;lt;object&amp;gt;().ToList();&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;items.Insert(0,
row.Key);&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var
obj = GetAnonymousObject(cols, items);&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;arr.Add(obj);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return
arr.ToArray();&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;private static
dynamic GetAnonymousObject(IEnumerable&amp;lt;string&amp;gt; columns,
IEnumerable&amp;lt;object&amp;gt; values)&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;IDictionary&amp;lt;string,
object&amp;gt; eo = new ExpandoObject() as IDictionary&amp;lt;string, object&amp;gt;;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int
i;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for
(i = 0; i &amp;lt; columns.Count(); i++)&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;eo.Add(columns.ElementAt&amp;lt;string&amp;gt;(i),
values.ElementAt&amp;lt;object&amp;gt;(i));&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return
eo;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;ExpandoObject&lt;/span&gt; is used to create dynamic object.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Now, to convert row
to column and get dynamic array:&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;a href=&quot;http://techbrij.com/pivot-c-array-datatable-convert-column-to-row-linq#&quot;&gt;?&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
var pivotArray =
data.ToPivotArray(&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;item
=&amp;gt; item.Year,&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;item
=&amp;gt; item.Product,&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;items
=&amp;gt; items.Any() ? items.Sum(x =&amp;gt; x.Sales) : 0);&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
You can easily
convert in JSON format&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
?&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
String json =
JsonConvert.SerializeObject(pivotArray, new KeyValuePairConverter());&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Here is the result:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicOU9zbAOxZid7FZfg6PUiACddw8chowJzHcDBk32VZeO3pNtmvy78DV7nBE9P3dEtgiysSLdaML6HJDdz3CqK3wBGJp4U7_Ti3YBoOUe9i7c6qUTRzp3QgzZNDPTF73JXKBLl1KiiqHLt/s1600/datatable-to-dynamic-list.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;160&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicOU9zbAOxZid7FZfg6PUiACddw8chowJzHcDBk32VZeO3pNtmvy78DV7nBE9P3dEtgiysSLdaML6HJDdz3CqK3wBGJp4U7_Ti3YBoOUe9i7c6qUTRzp3QgzZNDPTF73JXKBLl1KiiqHLt/s320/datatable-to-dynamic-list.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 16.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;C# DataTable to Pivot DataTable:&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Let us have a
DataTable with same data:&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
?&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
DataTable
myDataTable = new DataTable();&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
myDataTable.Columns.AddRange(new
DataColumn[3] { new DataColumn(&quot;Product&quot;), new
DataColumn(&quot;Year&quot;, typeof(int)), new DataColumn(&quot;Sales&quot;,
typeof(int)) });&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
myDataTable.Rows.Add(&quot;Product
1&quot;, 2009, 1212);&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
myDataTable.Rows.Add(&quot;Product
2&quot;, 2009, 522);&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
myDataTable.Rows.Add(&quot;Product
1&quot;, 2010, 1337);&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
myDataTable.Rows.Add(&quot;Product
2&quot;, 2011, 711);&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
myDataTable.Rows.Add(&quot;Product
2&quot;, 2012, 2245);&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
myDataTable.Rows.Add(&quot;Product
3&quot;, 2012, 1000);&amp;nbsp;&amp;nbsp; &lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
You can use the same
extension method to get Pivot DataTable like below.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
?&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
var data2 =
myDataTable.AsEnumerable().Select(x=&amp;gt; new { &lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Product
=x.Field&amp;lt;String&amp;gt;(&quot;Product&quot;), &lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Year=
x.Field&amp;lt;int&amp;gt;(&quot;Year&quot;), &lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Sales
= x.Field&amp;lt;int&amp;gt;(&quot;Sales&quot;) });&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DataTable
pivotDataTable =data2.ToPivotTable(&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;item
=&amp;gt; item.Year,&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;item
=&amp;gt; item.Product,&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;items
=&amp;gt; items.Any() ? items.Sum(x =&amp;gt; x.Sales) : 0);&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Here is the result:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLQNl6JHzxpreXkwj5ClxRyP3CNjdg-NRGFF8dxBc9TpRO3CQjO2LsyeA8HA2JA1nSeP7DJOPF9XRdYvA2gEFwcqPAZnJgE1_RoPkdUjSfj4Tm-MK0EzcR14NlNcm68Ri2FmkelGe9B650/s1600/pivot-datatable-linq.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;186&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLQNl6JHzxpreXkwj5ClxRyP3CNjdg-NRGFF8dxBc9TpRO3CQjO2LsyeA8HA2JA1nSeP7DJOPF9XRdYvA2gEFwcqPAZnJgE1_RoPkdUjSfj4Tm-MK0EzcR14NlNcm68Ri2FmkelGe9B650/s320/pivot-datatable-linq.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 16.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;DataTable to List&amp;lt;dynamic&amp;gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
If you need to
convert DataTable to List of dynamic object then use following extension
method:&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;a href=&quot;http://techbrij.com/pivot-c-array-datatable-convert-column-to-row-linq#&quot;&gt;?&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
public static
List&amp;lt;dynamic&amp;gt; ToDynamicList(this DataTable dt)&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var
list = new List&amp;lt;dynamic&amp;gt;();&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;foreach
(DataRow row in dt.Rows)&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dynamic
dyn = new ExpandoObject();&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;list.Add(dyn);&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;foreach
(DataColumn column in dt.Columns)&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var
dic = (IDictionary&amp;lt;string, object&amp;gt;)dyn;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dic[column.ColumnName]
= row[column];&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return
list;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Here is the result:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-4qBD_P5m6tB3XsC0fWuknpUuy5nFwAaBGMZNg09khfeiZGrC6H3PvmU0zn0l8oxPwNN8UgCTj6smo_dY1YnUAIg-ROfD2ApNI3sqlfoLL6D432YOwzWJ5LoigW8rHb3byoCUw1VMeQ4a/s1600/pivot-array-to-dynamic.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;189&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-4qBD_P5m6tB3XsC0fWuknpUuy5nFwAaBGMZNg09khfeiZGrC6H3PvmU0zn0l8oxPwNN8UgCTj6smo_dY1YnUAIg-ROfD2ApNI3sqlfoLL6D432YOwzWJ5LoigW8rHb3byoCUw1VMeQ4a/s320/pivot-array-to-dynamic.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 16.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Conclusion:&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
In this post, we
played with C# Array, DataTable and
implemented to convert row to column and get Pivot Array, DataTable and List of
dynamic object.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: #595959; font-family: Calibri; font-size: 9.0pt; margin: 0in;&quot;&gt;
From
&amp;lt;&lt;a href=&quot;http://techbrij.com/pivot-c-array-datatable-convert-column-to-row-linq&quot;&gt;http://techbrij.com/pivot-c-array-datatable-convert-column-to-row-linq&lt;/a&gt;&amp;gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://armoe.blogspot.com/feeds/8388106460481499045/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='http://armoe.blogspot.com/2016/06/pivot-c-array-or-datatable-convert.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/8388106460481499045'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/8388106460481499045'/><link rel='alternate' type='text/html' href='http://armoe.blogspot.com/2016/06/pivot-c-array-or-datatable-convert.html' title='Pivot C# Array or DataTable: Convert a Column To a Row with LINQ'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02277756216508959449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9ex23U5uFI_jN_8DcJpbuUC_DKjN_ClMTJyF_9fe9BmpdvPVPXJ69Obpo1hhHcBL81XPMnp4HvFGY_6j3INnO7JQcMLIro7T2nt0dmq7s1caUctqf4Fv_QBnau9jrBtQlwCx7JE1kWJIv/s72-c/c-array-pivot.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2065822655831694480.post-8210496367492561126</id><published>2016-06-17T15:47:00.001-07:00</published><updated>2016-06-17T15:47:15.918-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Solved Problem"/><title type='text'> Pivot data using LINQ</title><content type='html'>&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
CustID | OrderDate |
Qty&lt;br /&gt;
1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | 1/1/2008&amp;nbsp; | 100&lt;br /&gt;
2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | 1/2/2008&amp;nbsp; | 200&lt;br /&gt;
1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | 2/2/2008&amp;nbsp; | 350&lt;br /&gt;
2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | 2/28/2008 | 221&lt;br /&gt;
1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | 3/12/2008 | 250&lt;br /&gt;
2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | 3/15/2008 | 2150&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
List&amp;lt;CustData&amp;gt;
myList = GetCustData();&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
var query =
myList&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; .GroupBy(c =&amp;gt; c.CustId)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; .Select(g =&amp;gt; new {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CustId = g.Key,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Jan = g.Where(c =&amp;gt;
c.OrderDate.Month == 1).Sum(c =&amp;gt; c.Qty),&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Feb = g.Where(c =&amp;gt;
c.OrderDate.Month == 2).Sum(c =&amp;gt; c.Qty),&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; March = g.Where(c =&amp;gt;
c.OrderDate.Month == 3).Sum(c =&amp;gt; c.Qty)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://armoe.blogspot.com/feeds/8210496367492561126/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='http://armoe.blogspot.com/2016/06/pivot-data-using-linq.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/8210496367492561126'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/8210496367492561126'/><link rel='alternate' type='text/html' href='http://armoe.blogspot.com/2016/06/pivot-data-using-linq.html' title=' Pivot data using LINQ'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02277756216508959449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2065822655831694480.post-1245177277393207153</id><published>2016-06-17T15:45:00.003-07:00</published><updated>2016-06-17T15:45:46.308-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Solved Problem"/><title type='text'>Control Parent Page from UserControl(.ascx)</title><content type='html'>&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;Label lbl =
this.Parent.FindControl(&quot;lbl1&quot;) as Label;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lbl.Text = txt1.Text;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://armoe.blogspot.com/feeds/1245177277393207153/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='http://armoe.blogspot.com/2016/06/control-parent-page-from-usercontrolascx.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/1245177277393207153'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/1245177277393207153'/><link rel='alternate' type='text/html' href='http://armoe.blogspot.com/2016/06/control-parent-page-from-usercontrolascx.html' title='Control Parent Page from UserControl(.ascx)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02277756216508959449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2065822655831694480.post-8521256127901794974</id><published>2016-06-17T15:44:00.002-07:00</published><updated>2016-06-17T15:44:36.421-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="English Tutorial"/><title type='text'>Events in ASP.NET Master and Content Pages</title><content type='html'>&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Both master pages
and content pages can contain event handlers for controls. For controls, events
are handled locally—a control in a content page raises an event in the content
page, and a control in the master page raises an event in the master page. Controls
events are not sent from the content page to the master page. Similarly, you
cannot handle an event from a master page control in a content page.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
In some cases, the
same event is raised in both the content and the master page. For example, both
pages raise &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/system.web.ui.control.init.aspx&quot;&gt;Init&lt;/a&gt;
and &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/system.web.ui.control.load.aspx&quot;&gt;Load&lt;/a&gt;
events. The general rule for how events are raised is that the initialization
events are raised from the innermost control to the outermost one, and all
other events are raised from the outermost control to the innermost one. It is
helpful to remember that the master page is merged into the content page and
treated as a control in the content page.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
The following is the
sequence in which events occur when a master page is merged with a content
page:&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ol style=&quot;direction: ltr; font-family: Calibri; font-size: 11pt; margin-bottom: 0in; margin-left: 0.375in; margin-top: 0in; unicode-bidi: embed;&quot; type=&quot;1&quot;&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot; value=&quot;1&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Content page &lt;/span&gt;&lt;span style=&quot;font-size: 11pt; font-weight: bold;&quot;&gt;PreInit&lt;/span&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt; event.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Master page controls &lt;/span&gt;&lt;span style=&quot;font-size: 11pt; font-weight: bold;&quot;&gt;Init&lt;/span&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt; event.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Content controls &lt;/span&gt;&lt;span style=&quot;font-size: 11pt; font-weight: bold;&quot;&gt;Init&lt;/span&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt; event.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Master page &lt;/span&gt;&lt;span style=&quot;font-size: 11pt; font-weight: bold;&quot;&gt;Init&lt;/span&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt; event.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Content page &lt;/span&gt;&lt;span style=&quot;font-size: 11pt; font-weight: bold;&quot;&gt;Init&lt;/span&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt; event.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Content page &lt;/span&gt;&lt;span style=&quot;font-size: 11pt; font-weight: bold;&quot;&gt;Load&lt;/span&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt; event.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Master page &lt;/span&gt;&lt;span style=&quot;font-size: 11pt; font-weight: bold;&quot;&gt;Load&lt;/span&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt; event.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Master page controls &lt;/span&gt;&lt;span style=&quot;font-size: 11pt; font-weight: bold;&quot;&gt;Load&lt;/span&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt; event.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Content page controls &lt;/span&gt;&lt;span style=&quot;font-size: 11pt; font-weight: bold;&quot;&gt;Load&lt;/span&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt; event.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Content page &lt;/span&gt;&lt;span style=&quot;font-size: 11pt; font-weight: bold;&quot;&gt;PreRender&lt;/span&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt; event.&amp;nbsp; &lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Master page &lt;/span&gt;&lt;span style=&quot;font-size: 11pt; font-weight: bold;&quot;&gt;PreRender&lt;/span&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt; event.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Master page controls &lt;/span&gt;&lt;span style=&quot;font-size: 11pt; font-weight: bold;&quot;&gt;PreRender&lt;/span&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt; event.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Content page controls &lt;/span&gt;&lt;span style=&quot;font-size: 11pt; font-weight: bold;&quot;&gt;PreRender&lt;/span&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt; event.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Master page controls &lt;/span&gt;&lt;span style=&quot;font-size: 11pt; font-weight: bold;&quot;&gt;Unload&lt;/span&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt; event.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Content page controls &lt;/span&gt;&lt;span style=&quot;font-size: 11pt; font-weight: bold;&quot;&gt;Unload&lt;/span&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt; event.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Master page &lt;/span&gt;&lt;span style=&quot;font-size: 11pt; font-weight: bold;&quot;&gt;Unload&lt;/span&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt; event.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Content page &lt;/span&gt;&lt;span style=&quot;font-size: 11pt; font-weight: bold;&quot;&gt;Unload&lt;/span&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt; event.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin-left: .375in; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
The sequence of
events in master and content pages rarely is important for you as page
developer. However, if you are creating event handlers that depend on the
availability of certain controls, you will find it helpful to understand the
event sequence in master and content pages.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: #595959; font-family: Calibri; font-size: 9.0pt; margin: 0in;&quot;&gt;
From
&amp;lt;&lt;a href=&quot;https://msdn.microsoft.com/en-us/library/dct97kc3.aspx&quot;&gt;https://msdn.microsoft.com/en-us/library/dct97kc3.aspx&lt;/a&gt;&amp;gt;&amp;nbsp;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://armoe.blogspot.com/feeds/8521256127901794974/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='http://armoe.blogspot.com/2016/06/events-in-aspnet-master-and-content.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/8521256127901794974'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/8521256127901794974'/><link rel='alternate' type='text/html' href='http://armoe.blogspot.com/2016/06/events-in-aspnet-master-and-content.html' title='Events in ASP.NET Master and Content Pages'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02277756216508959449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2065822655831694480.post-5157282162416230249</id><published>2016-06-17T15:43:00.003-07:00</published><updated>2016-06-17T15:43:23.799-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Sharp"/><category scheme="http://www.blogger.com/atom/ns#" term="English Tutorial"/><title type='text'>Get List of Active Directory Users in C#</title><content type='html'>&lt;div style=&quot;font-family: Calibri; font-size: 18.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Introduction&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
This tip describes
how to list Active Directory users.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 18.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Using the Code&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
The below code
demonstrates how can we fetch Active Directory (AD) using Directory Service.
For this, I&#39;m using object array (Users) and here is the structure:&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Hide &amp;nbsp; Copy
Code&lt;/div&gt;
&lt;div lang=&quot;cs&quot; style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
public class
Users&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public string Email { get; set;
}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public string UserName { get; set;
}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public string DisplayName { get; set;
}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public bool isMapped { get; set;
}&lt;br /&gt;
}&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
The code below shows
how to fetch user information from Active Directory.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Hide &amp;nbsp; Shrink &lt;/div&gt;
&lt;div style=&quot;margin: 0in;&quot;&gt;
&lt;img height=&quot;16&quot; src=&quot;file:///C:\Users\MYDEV_PC\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png&quot; width=&quot;16&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;nbsp; Copy Code&lt;/div&gt;
&lt;div lang=&quot;cs&quot; style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
public
List&amp;lt;Users&amp;gt; GetADUsers()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; try&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; List&amp;lt;Users&amp;gt; lstADUsers =
new List&amp;lt;Users&amp;gt;();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string DomainPath =
&quot;LDAP://DC=xxxx,DC=com&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DirectoryEntry searchRoot = new
DirectoryEntry(DomainPath); &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DirectorySearcher search = new
DirectorySearcher(searchRoot);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; search.Filter =
&quot;(&amp;amp;(objectClass=user)(objectCategory=person))&quot;;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
search.PropertiesToLoad.Add(&quot;samaccountname&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
search.PropertiesToLoad.Add(&quot;mail&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; search.PropertiesToLoad.Add(&quot;usergroup&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
search.PropertiesToLoad.Add(&quot;displayname&quot;);//first
name&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SearchResult result;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SearchResultCollection resultCol
= search.FindAll();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (resultCol != null)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int counter = 0; counter
&amp;lt; resultCol.Count; counter++)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string UserNameEmailString
= string.Empty;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result =
resultCol[counter];&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if
(result.Properties.Contains(&quot;samaccountname&quot;) &amp;amp;&amp;amp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
result.Properties.Contains(&quot;mail&quot;) &amp;amp;&amp;amp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
result.Properties.Contains(&quot;displayname&quot;))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Users objSurveyUsers
= new Users();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; objSurveyUsers.Email
= (String)result.Properties[&quot;mail&quot;][0] + &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;^&quot; +
(String)result.Properties[&quot;displayname&quot;][0];&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; objSurveyUsers.UserName
= (String)result.Properties[&quot;samaccountname&quot;][0];&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
objSurveyUsers.DisplayName =
(String)result.Properties[&quot;displayname&quot;][0];&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
lstADUsers.Add(objSurveyUsers);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return lstADUsers;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; catch (Exception ex)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/div&gt;
&lt;div lang=&quot;cs&quot; style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
}&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Let&#39;s see what is
happening here...&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
The DirectoryEntry
class encapsulates an object in Active Directory Domain Services,
DirectoryEntry(DomainPath) initializes a new instance of the class that binds
this instance to the node in Active Directory Domain Services located at the
specified path, i.e., DomainPath.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
In
DirectorySearcher, create a DirectorySearcher object which searches for all
users in a domain. search.Filter =
&quot;(&amp;amp;(objectClass=user)(objectCategory=person))&quot; filters the
search. &lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
The search filter
syntax looks a bit complicated, but basically it filters the search results to
only include users - &quot;objectCategory=person&quot; and
&quot;objectClass=user&quot; - and excludes disabled user accounts by
performing a bitwise AND of the userAccountControl flags and the &quot;account
disabled&quot; flag. &lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Note&lt;/span&gt;: SAMAccountName is unique and also
indexed. sAMAccountName must be unique among all security principal objects
within the domain.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
search.FindAll();
retrieves all the elements that match the conditions defined.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Let&#39;s see how we get
the current login user.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Hide &amp;nbsp; Copy
Code&lt;/div&gt;
&lt;div lang=&quot;cs&quot; style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
public
string GetCurrentUser()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; try&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string userName =
HttpContext.Current.User.Identity.Name.Split(&#39;\\&#39;)[1].ToString();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string displayName =
GetAllADUsers().Where(x =&amp;gt; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x.UserName ==
userName).Select(x =&amp;gt; x.DisplayName).First();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return displayName;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; catch (Exception ex)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; { //Exception logic here &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
}&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Let&#39;s see what this
code snippet does: &lt;/div&gt;
&lt;ul style=&quot;direction: ltr; margin-bottom: 0in; margin-left: .375in; margin-top: 0in; unicode-bidi: embed;&quot; type=&quot;disc&quot;&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-family: Calibri; font-size: 11.0pt;&quot;&gt;HttpContext.Current.User.Identity
     returns the Windows identity object including AuthenticationType &lt;/span&gt;&lt;span style=&quot;font-family: Calibri; font-size: 11.0pt; font-style: italic;&quot;&gt;(&quot;ntml&quot;,
     &quot;kerberos&lt;/span&gt;&lt;span style=&quot;font-family: Calibri; font-size: 11.0pt;&quot;&gt;&quot;
     etc..), IsAuthenticated, Name (&quot;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri; font-size: 11.0pt; font-style: italic;&quot;&gt;Domain/username&lt;/span&gt;&lt;span style=&quot;font-family: Calibri; font-size: 11.0pt;&quot;&gt;&quot;). &lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-family: Calibri; font-size: 11.0pt;&quot;&gt;HttpContext.Current.User.Identity.Name
     returns &quot;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri; font-size: 11.0pt; font-style: italic;&quot;&gt;Domain\\username&lt;/span&gt;&lt;span style=&quot;font-family: Calibri; font-size: 11.0pt;&quot;&gt;&quot;&amp;nbsp;. &lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Hope this helps you
understand how directory service works with AD.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: #595959; font-family: Calibri; font-size: 9.0pt; margin: 0in;&quot;&gt;
From
&amp;lt;&lt;a href=&quot;http://www.codeproject.com/Tips/599697/Get-list-of-Active-Directory-users-in-Csharp&quot;&gt;http://www.codeproject.com/Tips/599697/Get-list-of-Active-Directory-users-in-Csharp&lt;/a&gt;&amp;gt;&amp;nbsp;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://armoe.blogspot.com/feeds/5157282162416230249/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='http://armoe.blogspot.com/2016/06/get-list-of-active-directory-users-in-c.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/5157282162416230249'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/5157282162416230249'/><link rel='alternate' type='text/html' href='http://armoe.blogspot.com/2016/06/get-list-of-active-directory-users-in-c.html' title='Get List of Active Directory Users in C#'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02277756216508959449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2065822655831694480.post-2635490053864300870</id><published>2016-06-17T15:42:00.002-07:00</published><updated>2016-06-17T15:42:17.831-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Sharp"/><category scheme="http://www.blogger.com/atom/ns#" term="English Tutorial"/><title type='text'>How to authenticate against the Active Directory by using Forms authentication and Visual C# .NET </title><content type='html'>&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
This article refers
to the following Microsoft .NET Framework Class Library namespaces: &lt;/div&gt;
&lt;ul style=&quot;direction: ltr; margin-bottom: 0in; margin-left: .375in; margin-top: 0in; unicode-bidi: embed;&quot; type=&quot;disc&quot;&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-family: Calibri; font-size: 11.0pt;&quot;&gt;System.Text&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-family: Calibri; font-size: 11.0pt;&quot;&gt;System.DirectoryServices&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-family: Calibri; font-size: 11.0pt;&quot;&gt;System.Security.Principal&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-family: Calibri; font-size: 11.0pt;&quot;&gt;System.Web.Security&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 10.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;SUMMARY&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
This step-by-step
article demonstrates how an ASP.NET application can use Forms authentication to
permit users to authenticate against the Active Directory by using the
Lightweight Directory Access Protocol (LDAP). After the user is authenticated
and redirected, you can use the Application_AuthenticateRequest method of the
Global.asax file to store a GenericPrincipal object in the HttpContext.User
property that flows throughout the request.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 16.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Create an ASP.NET Web application in Visual C# .NET&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Follow these steps
to create a new ASP.NET Web application named FormsAuthAd in Visual C# .NET: &lt;/div&gt;
&lt;ol style=&quot;direction: ltr; font-family: Calibri; font-size: 11pt; margin-bottom: 0in; margin-left: 0.375in; margin-top: 0in; unicode-bidi: embed;&quot; type=&quot;1&quot;&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot; value=&quot;1&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Start Microsoft Visual Studio
     .NET.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;On the File menu, point to
     New, and then click Project.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Click Visual C# Projects
     under Project Types, and then click ASP.NET Web Application under
     Templates.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;In the Location box, replace
     WebApplication1 with FormsAuthAd.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Click OK.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Right-click the References
     node in Solution Explorer, and then click Add Reference.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;On the .NET tab in the Add
     Reference dialog box, click System.DirectoryServices.dll, click Select,
     and then click OK.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 16.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Write the authentication code&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Follow these steps
to create a new class file named LdapAuthentication.cs: &lt;/div&gt;
&lt;ol style=&quot;direction: ltr; font-family: Calibri; font-size: 11pt; margin-bottom: 0in; margin-left: 0.375in; margin-top: 0in; unicode-bidi: embed;&quot; type=&quot;1&quot;&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot; value=&quot;1&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;In Solution Explorer,
     right-click the project node, point to Add, and then click Add New Item.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Click Class under Templates.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Type LdapAuthentication.cs in
     the Name box, and then click Open.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Replace the existing code in
     the LdapAuthentication.cs file with the following code.&lt;br /&gt;
          &lt;br /&gt;
          using System;&lt;br /&gt;
          using System.Text;&lt;br /&gt;
          using System.Collections;&lt;br /&gt;
          using System.DirectoryServices;&lt;br /&gt;
          &lt;br /&gt;
          namespace FormsAuth&lt;br /&gt;
          {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
          &amp;nbsp; public class
     LdapAuthentication&lt;br /&gt;
          &amp;nbsp; {&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp; private String _path;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp; private String
     _filterAttribute;&lt;br /&gt;
          &lt;br /&gt;
          public LdapAuthentication(String path)&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _path = path;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
         
     &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp; public bool
     IsAuthenticated(String domain, String username, String pwd)&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; String domainAndUsername
     = domain + @&quot;\&quot; + username;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DirectoryEntry entry =
     new DirectoryEntry(_path, domainAndUsername, pwd);&lt;br /&gt;
         
     &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
     {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//Bind to the
     native AdsObject to force
     authentication.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Object obj =
     entry.NativeObject;&lt;br /&gt;
          &lt;br /&gt;
          DirectorySearcher search = new DirectorySearcher(entry);&lt;br /&gt;
          &lt;br /&gt;
          search.Filter = &quot;(SAMAccountName=&quot; + username +
     &quot;)&quot;;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;search.PropertiesToLoad.Add(&quot;cn&quot;);&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SearchResult result =
     search.FindOne();&lt;br /&gt;
          &lt;br /&gt;
          if(null == result)&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;
          &amp;nbsp;
     &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return false;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
          &lt;br /&gt;
          //Update the new path to the user in the directory.&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_path =
     result.Path;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_filterAttribute =
     (String)result.Properties[&quot;cn&quot;][0];&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; catch (Exception
     ex)&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw new Exception(&quot;Error
     authenticating user. &quot; + ex.Message);&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
          &lt;br /&gt;
          return true;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
          &lt;br /&gt;
          public String GetGroups()&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DirectorySearcher search
     = new DirectorySearcher(_path);&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; search.Filter =
     &quot;(cn=&quot; + _filterAttribute + &quot;)&quot;;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
     search.PropertiesToLoad.Add(&quot;memberOf&quot;);&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; StringBuilder groupNames
     = new StringBuilder();&lt;br /&gt;
          &lt;br /&gt;
          try&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SearchResult result =
     search.FindOne();&lt;br /&gt;
          &lt;br /&gt;
          int propertyCount = result.Properties[&quot;memberOf&quot;].Count;&lt;br /&gt;
          &lt;br /&gt;
          String dn;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int equalsIndex,
     commaIndex;&lt;br /&gt;
         
     &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(int
     propertyCounter = 0; propertyCounter &amp;lt; propertyCount;
     propertyCounter++)&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dn =
     (String)result.Properties[&quot;memberOf&quot;][propertyCounter];&lt;br /&gt;
          &lt;br /&gt;
          equalsIndex = dn.IndexOf(&quot;=&quot;, 1);&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; commaIndex = dn.IndexOf(&quot;,&quot;,
     1);&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(-1 == equalsIndex)&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return null;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
     &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
          &lt;br /&gt;
          groupNames.Append(dn.Substring((equalsIndex + 1), (commaIndex -
     equalsIndex) - 1));&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; groupNames.Append(&quot;|&quot;);&lt;br /&gt;
          &lt;br /&gt;
          }&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; catch(Exception
     ex)&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw new
     Exception(&quot;Error obtaining group names. &quot; + ex.Message);&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
     }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return
     groupNames.ToString();&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
          &amp;nbsp;&amp;nbsp; }&lt;br /&gt;
          }&lt;br /&gt;
         
     &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
The authentication
code accepts a domain, a user name, a password, and a path to the tree in the
Active Directory. This code uses the LDAP directory provider.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
The code in the
Logon.aspx page calls the LdapAuthentication.IsAuthenticated method and passes
in the credentials that are collected from the user. Then, a DirectoryEntry
object is created with the path to the directory tree, the user name, and the
password. The user name must be in the &quot;domain\username&quot; format. The
DirectoryEntry object then tries to force the AdsObject binding by obtaining
the NativeObject property. If this succeeds, the CN attribute for the user is
obtained by creating a DirectorySearcher object and by filtering on the
SAMAccountName. After the user is authenticated, the IsAuthenticated method
returns true.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
To obtain a list of
groups that the user belongs to, this code calls the
LdapAuthentication.GetGroups method. The LdapAuthentication.GetGroups method
obtains a list of security and distribution groups that the user belongs to by
creating a DirectorySearcher object and by filtering according to the memberOf
attribute. This method returns a list of groups that is separated by pipes (|).&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Notice that the
LdapAuthentication.GetGroups method manipulates and truncates strings. This
reduces the length of the string that is stored in the authentication cookie.
If the string is not truncated, the format of each group appears as follows. &lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;
CN=...,...,DC=domain,DC=com&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
This can create a
very long string. If the length of this string is greater than the length of
the cookie, browsers may not accept the authentication cookie, and you will be
redirected to the logon page. However, if you are in a multi-domain
environment, you may have to keep the domain name with the group name because
groups in different domains can have the same group name. You have to keep the
domain name to differentiate one group from another.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Most browsers
support cookies of up to 4096 bytes. If this string may potentially exceed the
length of the cookie, you may want to store the group information in the
ASP.NET Cache object or in a database. Alternatively, you may want to encrypt
the group information and store this information in a hidden form field.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 16.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Write the Global.asax code&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
The code in the
Global.asax file provides an Application_AuthenticateRequest event handler.
This event handler retrieves the authentication cookie from the
Context.Request.Cookies collection, decrypts the cookie, and retrieves the list
of groups that will be stored in the FormsAuthenticationTicket.UserData
property. The groups appear in a pipe-separated list that is created in the
Logon.aspx page.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
The code parses the
string in a string array to create a GenericPrincipal object. After the
GenericPrincipal object is created, this object is placed in the
HttpContext.User property. &lt;/div&gt;
&lt;ol style=&quot;direction: ltr; font-family: Calibri; font-size: 11pt; margin-bottom: 0in; margin-left: 0.375in; margin-top: 0in; unicode-bidi: embed;&quot; type=&quot;1&quot;&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot; value=&quot;1&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;In Solution Explorer,
     right-click Global.asax, and then click View Code.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Add the following code at the
     top of the code-behind Global.asax.cs file:&lt;br /&gt;
          &lt;br /&gt;
          using System.Web.Security;&lt;br /&gt;
          using System.Security.Principal;&lt;br /&gt;
         
     &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Replace the existing empty
     event handler for the Application_AuthenticateRequest with the following
     code.&lt;br /&gt;
          &lt;br /&gt;
          void Application_AuthenticateRequest(Object sender, EventArgs
     e)&lt;br /&gt;
          {&lt;br /&gt;
          &amp;nbsp; String cookieName =
     FormsAuthentication.FormsCookieName;&lt;br /&gt;
          &amp;nbsp; HttpCookie authCookie =
     Context.Request.Cookies[cookieName];&lt;br /&gt;
          &lt;br /&gt;
          if(null == authCookie)&lt;br /&gt;
          &amp;nbsp; {//There is no authentication
     cookie.&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;br /&gt;
          &amp;nbsp;
     }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
          &amp;nbsp; FormsAuthenticationTicket
     authTicket = null;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
          &amp;nbsp; try&lt;br /&gt;
          &amp;nbsp; {&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp; authTicket =
     FormsAuthentication.Decrypt(authCookie.Value);&lt;br /&gt;
          &amp;nbsp; }&lt;br /&gt;
          &amp;nbsp; catch(Exception ex)&lt;br /&gt;
          &amp;nbsp; {&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp; //Write the exception to
     the Event Log.&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;br /&gt;
          &amp;nbsp; }&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
          &amp;nbsp; if(null == authTicket)&lt;br /&gt;
          &amp;nbsp; {//Cookie failed to
     decrypt.&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;
     return;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
          &amp;nbsp;
     }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
          &amp;nbsp; //When the ticket was
     created, the UserData property was assigned a&lt;br /&gt;
          &amp;nbsp; //pipe-delimited string of
     group names.&lt;br /&gt;
          &amp;nbsp; String[] groups =
     authTicket.UserData.Split(new char[]{&#39;|&#39;});&lt;br /&gt;
          &lt;br /&gt;
          //Create an Identity.&lt;br /&gt;
          &amp;nbsp; GenericIdentity id = new
     GenericIdentity(authTicket.Name, &quot;LdapAuthentication&quot;);&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
          &amp;nbsp; //This principal flows
     throughout the request.&lt;br /&gt;
          &amp;nbsp; GenericPrincipal principal =
     new GenericPrincipal(id, groups);&lt;br /&gt;
          &lt;br /&gt;
          Context.User = principal;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
          }&lt;br /&gt;
         
     &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 16.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Modify the Web.config file&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
In this section, you
configure the &amp;lt;forms&amp;gt;, the &amp;lt;authentication&amp;gt;, and the
&amp;lt;authorization&amp;gt; elements in the Web.config file. With these changes, only
authenticated users can access the application, and unauthenticated requests
are redirected to a Logon.aspx page. You can modify this configuration to
permit only certain users and groups access to the application.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Replace the existing
code in the Web.config file with the following code. &lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;
?&amp;gt;&lt;br /&gt;
&amp;lt;configuration&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;lt;system.web&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;authentication
mode=&quot;Forms&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;forms
loginUrl=&quot;logon.aspx&quot; name=&quot;adAuthCookie&quot;
timeout=&quot;10&quot; path=&quot;/&quot; &amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/forms&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/authentication&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;authorization&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;deny users=&quot;?&quot;
/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;allow users=&quot;*&quot;
/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/authorization&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;identity
impersonate=&quot;true&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp;
&amp;lt;/system.web&amp;gt;&lt;br /&gt;
&amp;lt;/configuration&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Notice the
&amp;lt;identity impersonate=&quot;true&quot; /&amp;gt; configuration element. This
causes ASP.NET to impersonate the account that is configured as the anonymous
account from Microsoft Internet Information Services (IIS). As a result of this
configuration, all requests to this application run under the security context
of the configured account. The user provides credentials to authenticate
against the Active Directory, but the account that accesses the Active
Directory is the configured account. For more information, see the &lt;a href=&quot;https://support.microsoft.com/&quot;&gt;References&lt;/a&gt; section.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 16.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Configure IIS for anonymous authentication&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
To configure IIS for
anonymous authentication, follow these steps: &lt;/div&gt;
&lt;ol style=&quot;direction: ltr; font-family: Calibri; font-size: 11pt; margin-bottom: 0in; margin-left: 0.375in; margin-top: 0in; unicode-bidi: embed;&quot; type=&quot;1&quot;&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot; value=&quot;1&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;In IIS, expand the computer
     node for your server, expand &lt;/span&gt;&lt;span style=&quot;font-size: 11pt; font-weight: bold;&quot;&gt;Web Sites&lt;/span&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;, expand &lt;/span&gt;&lt;span style=&quot;font-size: 11pt; font-weight: bold;&quot;&gt;Default Web
     Site&lt;/span&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;,
     right-click &lt;/span&gt;&lt;span style=&quot;font-size: 11pt; font-weight: bold;&quot;&gt;FormsAuthAd&lt;/span&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;, and then click &lt;/span&gt;&lt;span style=&quot;font-size: 11pt; font-weight: bold;&quot;&gt;Properties&lt;/span&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;. &lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Click the &lt;/span&gt;&lt;span style=&quot;font-size: 11pt; font-weight: bold;&quot;&gt;Directory
     Security Tab&lt;/span&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;,
     and then click &lt;/span&gt;&lt;span style=&quot;font-size: 11pt; font-weight: bold;&quot;&gt;Edit&lt;/span&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt; under &lt;/span&gt;&lt;span style=&quot;font-size: 11pt; font-weight: bold;&quot;&gt;Anonymous Access and Authentication Control&lt;/span&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Make the anonymous account
     for the application an account that has permission to the Active
     Directory. &lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Click to clear the Allow IIS
     To Control Password check box. &lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;In the “Authenticated Access”
     section, uncheck the “Integrated Windows Authentication” check box. &lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Click OK.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Click Apply&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
The default
IUSR_computername account does not have permission to the Active Directory.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 16.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Create the Logon.aspx page&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Follow these steps
to create a new ASP.NET Web Form named Logon.aspx: &lt;/div&gt;
&lt;ol style=&quot;direction: ltr; font-family: Calibri; font-size: 11pt; margin-bottom: 0in; margin-left: 0.375in; margin-top: 0in; unicode-bidi: embed;&quot; type=&quot;1&quot;&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot; value=&quot;1&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;In Solution Explorer,
     right-click the project node, point to Add, and then click Add Web Form.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Type Logon.aspx in the Name
     box, and then click Open.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;In Solution Explorer,
     right-click Logon.aspx, and then click View Designer.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Click the HTML tab in the
     Designer.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Replace the existing code
     with the following code.&lt;br /&gt;
          &amp;lt;%@ Page language=&quot;c#&quot; AutoEventWireup=&quot;true&quot;
     %&amp;gt;&lt;br /&gt;
          &amp;lt;%@ Import Namespace=&quot;FormsAuth&quot; %&amp;gt;&lt;br /&gt;
          &amp;lt;html&amp;gt;&lt;br /&gt;
          &amp;nbsp;
     &amp;lt;body&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;form
     id=&quot;Login&quot; method=&quot;post&quot;
     runat=&quot;server&quot;&amp;gt;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:Label
     ID=&quot;Label1&quot; Runat=server &amp;gt;Domain:&amp;lt;/asp:Label&amp;gt;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:TextBox
     ID=&quot;txtDomain&quot; Runat=server &amp;gt;&amp;lt;/asp:TextBox&amp;gt;&amp;lt;br&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:Label
     ID=&quot;Label2&quot; Runat=server &amp;gt;Username:&amp;lt;/asp:Label&amp;gt;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:TextBox
     ID=txtUsername Runat=server &amp;gt;&amp;lt;/asp:TextBox&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:Label
     ID=&quot;Label3&quot; Runat=server &amp;gt;Password:&amp;lt;/asp:Label&amp;gt;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:TextBox
     ID=&quot;txtPassword&quot; Runat=server
     TextMode=Password&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:Button
     ID=&quot;btnLogin&quot; Runat=server Text=&quot;Login&quot; OnClick=&quot;Login_Click&quot;&amp;gt;&amp;lt;/asp:Button&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:Label
     ID=&quot;errorLabel&quot; Runat=server
     ForeColor=#ff3300&amp;gt;&amp;lt;/asp:Label&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:CheckBox
     ID=chkPersist Runat=server Text=&quot;Persist Cookie&quot; /&amp;gt;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;
     &amp;lt;/form&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
          &amp;nbsp; &amp;lt;/body&amp;gt;&lt;br /&gt;
          &amp;lt;/html&amp;gt;&lt;br /&gt;
          &amp;lt;script runat=server&amp;gt;&lt;br /&gt;
          void Login_Click(Object sender, EventArgs e)&lt;br /&gt;
          {&lt;br /&gt;
          &amp;nbsp; String adPath = &quot;LDAP://corp.com&quot;;
     //Fully-qualified Domain Name&lt;br /&gt;
          &amp;nbsp; LdapAuthentication adAuth =
     new LdapAuthentication(adPath);&lt;br /&gt;
          &amp;nbsp; try&lt;br /&gt;
          &amp;nbsp; {&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp; if(true ==
     adAuth.IsAuthenticated(txtDomain.Text, txtUsername.Text,
     txtPassword.Text))&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; String groups =
     adAuth.GetGroups();&lt;br /&gt;
          &lt;br /&gt;
          //Create the ticket, and add the groups.&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bool isCookiePersistent =
     chkPersist.Checked;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FormsAuthenticationTicket
     authTicket = new FormsAuthenticationTicket(1,&amp;nbsp; txtUsername.Text,&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DateTime.Now,
     DateTime.Now.AddMinutes(60), isCookiePersistent, groups);&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Encrypt the
     ticket.&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; String encryptedTicket =
     FormsAuthentication.Encrypt(authTicket);&lt;br /&gt;
         
     &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Create a cookie, and
     then add the encrypted ticket to the cookie as data.&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HttpCookie authCookie =
     new HttpCookie(FormsAuthentication.FormsCookieName,
     encryptedTicket);&lt;br /&gt;
          &lt;br /&gt;
          if(true == isCookiePersistent)&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;authCookie.Expires =
     authTicket.Expiration;&lt;br /&gt;
         
     &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Add the cookie to the
     outgoing cookies collection.&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
     Response.Cookies.Add(authCookie);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
          &lt;br /&gt;
          //You can redirect now.&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
     Response.Redirect(FormsAuthentication.GetRedirectUrl(txtUsername.Text,
     false));&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; errorLabel.Text =
     &quot;Authentication did not succeed. Check user name and
     password.&quot;;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
          &amp;nbsp; }&lt;br /&gt;
          &amp;nbsp; catch(Exception ex)&lt;br /&gt;
          &amp;nbsp; {&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp; errorLabel.Text =
     &quot;Error authenticating. &quot; + ex.Message;&lt;br /&gt;
          &amp;nbsp; }&lt;br /&gt;
          }&lt;br /&gt;
          &amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Modify the path in the
     Logon.aspx page to point to your LDAP Directory server.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
The Logon.aspx page
is a page that collects the information from the user and call methods on the
LdapAuthentication class. After the code authenticates the user and obtains a
list of groups, the code creates a FormsAuthenticationTicket object, encrypts the
ticket, adds the encrypted ticket to a cookie, adds the cookie to the
HttpResponse.Cookies collection, and then redirects the request to the URL that
was originally requested.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 16.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Modify the WebForm1.aspx page&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
The WebForm1.aspx
page is the page that is requested originally. When the user requests this
page, the request is redirected to the Logon.aspx page. After the request is
authenticated, the request is redirected to the WebForm1.aspx page. &lt;/div&gt;
&lt;ol style=&quot;direction: ltr; font-family: Calibri; font-size: 11pt; margin-bottom: 0in; margin-left: 0.375in; margin-top: 0in; unicode-bidi: embed;&quot; type=&quot;1&quot;&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot; value=&quot;1&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;In Solution Explorer,
     right-click WebForm1.aspx, and then click View Designer.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Click the HTML tab in the
     Designer.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Replace the existing code
     with the following code.&lt;br /&gt;
          &lt;br /&gt;
          &amp;lt;%@ Page language=&quot;c#&quot; AutoEventWireup=&quot;true&quot;
     %&amp;gt;&lt;br /&gt;
          &amp;lt;%@ Import Namespace=&quot;System.Security.Principal&quot;
     %&amp;gt;&lt;br /&gt;
          &amp;lt;html&amp;gt;&lt;br /&gt;
          &amp;nbsp;
     &amp;lt;body&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;form
     id=&quot;Form1&quot; method=&quot;post&quot; runat=&quot;server&quot;&amp;gt;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:Label
     ID=&quot;lblName&quot; Runat=server /&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:Label
     ID=&quot;lblAuthType&quot; Runat=server /&amp;gt;&lt;br /&gt;
          &amp;nbsp;&amp;nbsp;&amp;nbsp;
     &amp;lt;/form&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
          &amp;nbsp; &amp;lt;/body&amp;gt;&lt;br /&gt;
          &amp;lt;/html&amp;gt;&lt;br /&gt;
          &amp;lt;script runat=server&amp;gt;&lt;br /&gt;
          void Page_Load(Object sender, EventArgs e)&lt;br /&gt;
          {&lt;br /&gt;
          &amp;nbsp; lblName.Text = &quot;Hello
     &quot; + Context.User.Identity.Name + &quot;.&quot;;&lt;br /&gt;
          &amp;nbsp; lblAuthType.Text = &quot;You
     were authenticated using &quot; +&amp;nbsp;&amp;nbsp;
     Context.User.Identity.AuthenticationType + &quot;.&quot;;&lt;br /&gt;
          }&lt;br /&gt;
          &amp;lt;/script&amp;gt;&lt;br /&gt;
         
     &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Save all files, and then
     compile the project.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Request the WebForm1.aspx
     page. Notice that you are redirected to Logon.aspx.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Type the logon credentials,
     and then click Submit. When you are redirected to WebForm1.aspx, notice
     that your user name appears and that LdapAuthentication is the
     authentication type for the Context.User.AuthenticationType property.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Note Microsoft
recommends that you use Secure Sockets Layer (SSL) encryption when you use
Forms authentication. This is because the user is identified based on the
authentication cookie, and SSL encryption on this application prevents anyone
from compromising the authentication cookie and any other valuable information
that is being transmitted.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://armoe.blogspot.com/feeds/2635490053864300870/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='http://armoe.blogspot.com/2016/06/how-to-authenticate-against-active.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/2635490053864300870'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/2635490053864300870'/><link rel='alternate' type='text/html' href='http://armoe.blogspot.com/2016/06/how-to-authenticate-against-active.html' title='How to authenticate against the Active Directory by using Forms authentication and Visual C# .NET '/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02277756216508959449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2065822655831694480.post-7488336703064636425</id><published>2016-06-17T15:40:00.000-07:00</published><updated>2016-06-17T15:40:19.563-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Sharp"/><category scheme="http://www.blogger.com/atom/ns#" term="English Tutorial"/><title type='text'>How to implement impersonation in an ASP.NET application </title><content type='html'>&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
This article refers
to the following Microsoft .NET Framework Class Library namespaces: &lt;/div&gt;
&lt;ul style=&quot;direction: ltr; margin-bottom: 0in; margin-left: .375in; margin-top: 0in; unicode-bidi: embed;&quot; type=&quot;disc&quot;&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-family: Calibri; font-size: 11.0pt;&quot;&gt;System.Web.Security&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-family: Calibri; font-size: 11.0pt;&quot;&gt;System.Security.Principal&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-family: Calibri; font-size: 11.0pt;&quot;&gt;System.Runtime.InteropServices&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 10.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;SUMMARY&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
This article
describes different ways to implement impersonation in an ASP.NET application. &lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 10.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ul style=&quot;direction: ltr; margin-bottom: 0in; margin-left: .375in; margin-top: 0in; unicode-bidi: embed;&quot; type=&quot;disc&quot;&gt;
&lt;/ul&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Note You can use the
following code to determine what user the thread is executing as: &lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;
System.Security.Principal.WindowsIdentity.GetCurrent().Name&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 16.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Impersonate the IIS Authenticated Account or User&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
To impersonate the
Microsoft Internet Information Services (IIS) authenticating user on every
request for every page in an ASP.NET application, you must include an
&amp;lt;identity&amp;gt; tag in the Web.config file of this application and set the
impersonate attribute to true. For example: &lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;
&amp;lt;identity impersonate=&quot;true&quot;
/&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 16.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Impersonate a Specific User for All the Requests of an
ASP.NET Application&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
To impersonate a
specific user for all the requests on all pages of an ASP.NET application, you
can specify the userName and password attributes in the &amp;lt;identity&amp;gt; tag of
the Web.config file for that application. For example: &lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;
&amp;lt;identity impersonate=&quot;true&quot; userName=&quot;accountname&quot;
password=&quot;password&quot;
/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Note The identity of
the process that impersonates a specific user on a thread must have the
&quot;Act as part of the operating system&quot; privilege. By default, the
Aspnet_wp.exe process runs under a computer account named ASPNET. However, this
account does not have the required privileges to impersonate a specific user.
You receive an error message if you try to impersonate a specific user. This
information applies only to the .NET Framework 1.0. This privilege is not
required for the .NET Framework 1.1.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
To work around this
problem, use one of the following methods: &lt;/div&gt;
&lt;ul style=&quot;direction: ltr; margin-bottom: 0in; margin-left: .375in; margin-top: 0in; unicode-bidi: embed;&quot; type=&quot;disc&quot;&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-family: Calibri; font-size: 11.0pt;&quot;&gt;Grant the &quot;Act as part
     of the operating system&quot; privilege to the ASPNET account (the least
     privileged account).&lt;br /&gt;
          &lt;br /&gt;
          Note Although you can use this method to work around the problem,
     Microsoft does not recommend this method.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-family: Calibri; font-size: 11.0pt;&quot;&gt;Change the account that the
     Aspnet_wp.exe process runs under to the System account in the
     &amp;lt;processModel&amp;gt; configuration section of the Machine.config file.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;a href=&quot;https://support.microsoft.com/&quot;&gt;back to the top&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 16.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Impersonate the Authenticating User in Code&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
To impersonate the
authenticating user (User.Identity) only when you run a particular section of
code, you can use the code to follow. This method requires that the
authenticating user identity is of type WindowsIdentity.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Visual Basic .NET&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;
Dim impersonationContext As
System.Security.Principal.WindowsImpersonationContext&lt;br /&gt;
Dim currentWindowsIdentity As System.Security.Principal.WindowsIdentity&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
currentWindowsIdentity
= CType(User.Identity,
System.Security.Principal.WindowsIdentity)&lt;br /&gt;
impersonationContext = currentWindowsIdentity.Impersonate()&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&#39;Insert your code
that runs under the security context of the authenticating user here.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
impersonationContext.Undo()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Visual C# .NET&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;
System.Security.Principal.WindowsImpersonationContext
impersonationContext;&lt;br /&gt;
impersonationContext = &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;
((System.Security.Principal.WindowsIdentity)User.Identity).Impersonate();&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
//Insert your code
that runs under the security context of the authenticating user here.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
impersonationContext.Undo();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Visual J# .NET&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;
System.Security.Principal.WindowsImpersonationContext
impersonationContext;&lt;br /&gt;
impersonationContext = &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;
((System.Security.Principal.WindowsIdentity)get_User().get_Identity()).Impersonate();&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
//Insert your code
that runs under the security context of the authenticating user here.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
impersonationContext.Undo();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 16.0pt; margin: 0in;&quot;&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Impersonate a Specific User in Code&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
To impersonate a
specific user only when you run a particular section of code, use the following
code:&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Visual Basic .NET&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;
&amp;lt;%@ Page Language=&quot;VB&quot; %&amp;gt;&lt;br /&gt;
&amp;lt;%@ Import Namespace = &quot;System.Web&quot; %&amp;gt;&lt;br /&gt;
&amp;lt;%@ Import Namespace = &quot;System.Web.Security&quot; %&amp;gt;&lt;br /&gt;
&amp;lt;%@ Import Namespace = &quot;System.Security.Principal&quot; %&amp;gt;&lt;br /&gt;
&amp;lt;%@ Import Namespace = &quot;System.Runtime.InteropServices&quot; %&amp;gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;lt;script
runat=server&amp;gt;&lt;br /&gt;
Dim LOGON32_LOGON_INTERACTIVE As Integer = 2&lt;br /&gt;
Dim LOGON32_PROVIDER_DEFAULT As Integer = 0&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Dim
impersonationContext As WindowsImpersonationContext&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Declare Function
LogonUserA Lib &quot;advapi32.dll&quot; (ByVal lpszUsername As String,
_&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ByVal lpszDomain
As String, _&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ByVal
lpszPassword As String, _&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ByVal dwLogonType
As Integer, _&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ByVal
dwLogonProvider As Integer, _&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ByRef phToken As
IntPtr) As Integer&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Declare Auto
Function DuplicateToken Lib &quot;advapi32.dll&quot; ( _&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ByVal
ExistingTokenHandle As IntPtr, _&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ByVal ImpersonationLevel
As Integer, _&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ByRef
DuplicateTokenHandle As IntPtr) As Integer&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Declare Auto
Function RevertToSelf Lib &quot;advapi32.dll&quot; () As Long&lt;br /&gt;
Declare Auto Function CloseHandle Lib &quot;kernel32.dll&quot; (ByVal handle As
IntPtr) As Long&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Public Sub
Page_Load(ByVal s As Object, ByVal e As EventArgs)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; If
impersonateValidUser(&quot;username&quot;, &quot;domain&quot;,
&quot;password&quot;) Then&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;Insert your code that runs under
the security context of a specific user here.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; undoImpersonation()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Else&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;Your impersonation failed.
Therefore, include a fail-safe mechanism here.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;br /&gt;
End Sub&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Private Function
impersonateValidUser(ByVal userName As String, _&lt;br /&gt;
ByVal domain As String, ByVal password As String) As Boolean&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Dim
tempWindowsIdentity As WindowsIdentity&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim token As IntPtr =
IntPtr.Zero&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim tokenDuplicate As IntPtr =
IntPtr.Zero&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; impersonateValidUser = False&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
If RevertToSelf()
Then&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If LogonUserA(userName, domain,
password, LOGON32_LOGON_INTERACTIVE, &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
LOGON32_PROVIDER_DEFAULT, token) &amp;lt;&amp;gt; 0 Then&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If DuplicateToken(token, 2,
tokenDuplicate) &amp;lt;&amp;gt; 0 Then&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tempWindowsIdentity = New
WindowsIdentity(tokenDuplicate)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; impersonationContext =
tempWindowsIdentity.Impersonate()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If Not
impersonationContext Is Nothing Then&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; impersonateValidUser
= True&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; If Not
tokenDuplicate.Equals(IntPtr.Zero) Then&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CloseHandle(tokenDuplicate)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; If Not token.Equals(IntPtr.Zero)
Then&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CloseHandle(token)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;br /&gt;
End Function&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Private Sub
undoImpersonation()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; impersonationContext.Undo()&lt;br /&gt;
End Sub&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Visual C# .NET&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;
&amp;lt;%@ Page Language=&quot;C#&quot;%&amp;gt;&lt;br /&gt;
&amp;lt;%@ Import Namespace = &quot;System.Web&quot; %&amp;gt;&lt;br /&gt;
&amp;lt;%@ Import Namespace = &quot;System.Web.Security&quot; %&amp;gt;&lt;br /&gt;
&amp;lt;%@ Import Namespace = &quot;System.Security.Principal&quot; %&amp;gt;&lt;br /&gt;
&amp;lt;%@ Import Namespace = &quot;System.Runtime.InteropServices&quot; %&amp;gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;lt;script
runat=server&amp;gt;&lt;br /&gt;
public const int LOGON32_LOGON_INTERACTIVE = 2;&lt;br /&gt;
public const int LOGON32_PROVIDER_DEFAULT = 0;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
WindowsImpersonationContext
impersonationContext; &lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
[DllImport(&quot;advapi32.dll&quot;)]&lt;br /&gt;
public static extern int LogonUserA(String lpszUserName,
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;String
lpszDomain,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;String lpszPassword,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int dwLogonType,
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int
dwLogonProvider,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ref IntPtr
phToken);&lt;br /&gt;
[DllImport(&quot;advapi32.dll&quot;, CharSet=CharSet.Auto,
SetLastError=true)]&lt;br /&gt;
public static extern int DuplicateToken(IntPtr hToken,
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int impersonationLevel,&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ref IntPtr
hNewToken);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;br /&gt;
[DllImport(&quot;advapi32.dll&quot;, CharSet=CharSet.Auto,
SetLastError=true)]&lt;br /&gt;
public static extern bool RevertToSelf();&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
[DllImport(&quot;kernel32.dll&quot;,
CharSet=CharSet.Auto)]&lt;br /&gt;
public static extern&amp;nbsp; bool
CloseHandle(IntPtr handle);&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
public void
Page_Load(Object s, EventArgs
e)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(impersonateValidUser(&quot;username&quot;,
&quot;domain&quot;,
&quot;password&quot;))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//Insert
your code that runs under the security context of a specific user
here.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;undoImpersonation();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//Your
impersonation failed. Therefore, include a fail-safe mechanism
here.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
}&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
private bool
impersonateValidUser(String userName, String domain, String
password)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;WindowsIdentity
tempWindowsIdentity;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;IntPtr token = IntPtr.Zero;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;IntPtr tokenDuplicate =
IntPtr.Zero;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
if(RevertToSelf())&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(LogonUserA(userName,
domain, password, LOGON32_LOGON_INTERACTIVE, &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;LOGON32_PROVIDER_DEFAULT,
ref token) !=
0)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(DuplicateToken(token,
2, ref tokenDuplicate) != 0) &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;tempWindowsIdentity
= new
WindowsIdentity(tokenDuplicate);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;impersonationContext
=
tempWindowsIdentity.Impersonate();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if
(impersonationContext !=
null)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CloseHandle(token);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CloseHandle(tokenDuplicate);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return
true;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(token!=
IntPtr.Zero)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CloseHandle(token);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(tokenDuplicate!=IntPtr.Zero)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CloseHandle(tokenDuplicate);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return false;&lt;br /&gt;
}&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
private void
undoImpersonation()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;impersonationContext.Undo();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Visual J# .NET&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;
&amp;lt;%@ Page language=&quot;VJ#&quot; %&amp;gt;&lt;br /&gt;
&amp;lt;%@ Import Namespace=&quot;System.Web&quot; %&amp;gt;&lt;br /&gt;
&amp;lt;%@ Import Namespace=&quot;System.Web.Security&quot; %&amp;gt;&lt;br /&gt;
&amp;lt;%@ Import Namespace=&quot;System.Security.Principal&quot; %&amp;gt;&lt;br /&gt;
&amp;lt;%@ Import Namespace=&quot;System.Runtime.InteropServices&quot; %&amp;gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;lt;script
runat=server&amp;gt;&lt;br /&gt;
public static int LOGON32_LOGON_INTERACTIVE = 2;&lt;br /&gt;
public static int LOGON32_PROVIDER_DEFAULT = 0;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
WindowsImpersonationContext
impersonationContext; &lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
/** @attribute
DllImport(&quot;advapi32.dll&quot;) */ &lt;br /&gt;
public static native int LogonUserA(String lpszUserName,
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;String lpszDomain,
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;String lpszPassword,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int dwLogonType,
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int dwLogonProvider,
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.IntPtr[] phToken);&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
/** @attribute
DllImport(&quot;advapi32.dll&quot;,&lt;br /&gt;
&amp;nbsp;CharSet=CharSet.Auto, SetLastError=true)
*/ &lt;br /&gt;
public static native int DuplicateToken(System.IntPtr
hToken,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int
impersonationLevel,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.IntPtr[] hNewToken);&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
/** @attribute
DllImport(&quot;kernel32.dll&quot;,CharSet=CharSet.Auto) */ &lt;br /&gt;
public static native&amp;nbsp; boolean
CloseHandle(System.IntPtr[] handle);&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
/** @attribute
DllImport(&quot;advapi32.dll&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
CharSet=CharSet.Auto,SetLastError=true)
*/&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
public static native boolean RevertToSelf();&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
public void
Page_Load(Object s, System.EventArgs
e)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(impersonateValidUser(&quot;username&quot;,
&quot;domain&quot;, &quot;
password&quot;))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//Insert
your code that runs under the security context of a specific user
here.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;undoImpersonation();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//Your
impersonation failed. Therefore, include a fail-safe mechanism
here.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
}&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
private boolean
impersonateValidUser(String userName, String domain, String
password)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;WindowsIdentity
tempWindowsIdentity;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.IntPtr[] token = new
System.IntPtr[1];&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.IntPtr[] tokenDuplicate
= new System.IntPtr[1];&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
if(RevertToSelf())&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(LogonUserA(userName,
domain, password, LOGON32_LOGON_INTERACTIVE, &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;LOGON32_PROVIDER_DEFAULT,
token) !=
0)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(DuplicateToken(token[0],
2, tokenDuplicate) != 0) &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;tempWindowsIdentity
= new
WindowsIdentity(tokenDuplicate[0]);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;impersonationContext
=
tempWindowsIdentity.Impersonate();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if
(impersonationContext !=
null)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CloseHandle(tokenDuplicate);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CloseHandle(token);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return
true;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(!token[0].Equals(System.IntPtr.Zero))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CloseHandle(token);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(!tokenDuplicate[0].Equals(System.IntPtr.Zero))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CloseHandle(tokenDuplicate);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return false;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
}&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
private void
undoImpersonation()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;impersonationContext.Undo();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Note The identity of
the process that impersonates a specific user on a thread must have the
&quot;Act as part of the operating system&quot; privilege if the Aspnet_wp.exe
process is running on a Microsoft Windows 2000-based computer. The &quot;Act as
part of the operating system&quot; privilege is not required if the
Aspnet_wp.exe process is running on a Windows XP-based computer or on a Windows
Server 2003-based computer. By default, the Aspnet_wp.exe process runs under a
computer account named ASPNET. However, this account does not have the required
privileges to impersonate a specific user. You receive an error message if you
try to impersonate a specific user. .&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
To work around this
problem, use one of the following methods: &lt;/div&gt;
&lt;br /&gt;
&lt;ul style=&quot;direction: ltr; margin-bottom: 0in; margin-left: .375in; margin-top: 0in; unicode-bidi: embed;&quot; type=&quot;disc&quot;&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-family: Calibri; font-size: 11.0pt;&quot;&gt;Grant the &quot;Act as part
     of the operating system&quot; privilege to the ASPNET account.&lt;br /&gt;
          &lt;br /&gt;
          Note We do not recommend this method to work around the problem.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot;&gt;&lt;span style=&quot;font-family: Calibri; font-size: 11.0pt;&quot;&gt;Change the account that the
     Aspnet_wp.exe process runs under to the System account in the
     &amp;lt;processModel&amp;gt; configuration section of the Machine.config file.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;color: #595959; font-family: Calibri; font-size: 9.0pt; margin: 0in;&quot;&gt;
From
&amp;lt;&lt;a href=&quot;https://support.microsoft.com/en-us/kb/306158&quot;&gt;https://support.microsoft.com/en-us/kb/306158&lt;/a&gt;&amp;gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://armoe.blogspot.com/feeds/7488336703064636425/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='http://armoe.blogspot.com/2016/06/how-to-implement-impersonation-in.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/7488336703064636425'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/7488336703064636425'/><link rel='alternate' type='text/html' href='http://armoe.blogspot.com/2016/06/how-to-implement-impersonation-in.html' title='How to implement impersonation in an ASP.NET application '/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02277756216508959449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2065822655831694480.post-8153869845909090700</id><published>2016-06-17T15:35:00.003-07:00</published><updated>2016-06-17T15:35:52.522-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="English Tutorial"/><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="Solved Problem"/><title type='text'>How allow user to only view and select years with ajax calendar?</title><content type='html'>&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&amp;lt;form
id=&quot;form1&quot; runat=&quot;server&quot;&amp;gt;&lt;br /&gt;
&amp;lt;asp:scriptmanager id=&quot;ScriptManager1&quot; runat=&quot;server&quot;
xmlns:asp=&quot;#unknown&quot;&amp;gt;&amp;lt;/asp:scriptmanager&amp;gt;&lt;br /&gt;
&amp;lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot;&amp;gt;&lt;br /&gt;
function onCalendarShown() {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; var cal =
$find(&quot;calendar1&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; cal._switchMode(&quot;years&quot;,
true); &lt;br /&gt;
&amp;nbsp;&amp;nbsp; if (cal._yearsBody) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (var i = 0; i &amp;lt;
cal._yearsBody.rows.length; i++) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var row = cal._yearsBody.rows[i];&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (var j = 0; j &amp;lt;
row.cells.length; j++) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Sys.UI.DomEvent.addHandler(row.cells[j].firstChild, &quot;click&quot;,
call);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
function onCalendarHidden() {&lt;br /&gt;
&amp;nbsp; var cal =
$find(&quot;calendar1&quot;);&lt;br /&gt;
&amp;nbsp; if (cal._yearsBody) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (var i = 0; i &amp;lt;
cal._yearsBody.rows.length; i++) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var row =
cal._yearsBody.rows[i];&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (var j = 0; j &amp;lt;
row.cells.length; j++) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sys.UI.DomEvent.removeHandler(row.cells[j].firstChild,
&quot;click&quot;, call);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function call(eventElement) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; var target =
eventElement.target;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; switch (target.mode) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case &quot;year&quot;:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var cal =
$find(&quot;calendar1&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
cal.set_selectedDate(target.date);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cal._blur.post(true);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cal.raiseDateSelectionChanged();
break;&lt;br /&gt;
&amp;nbsp;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;asp:textbox id=&quot;TextBox1&quot; runat=&quot;server&quot; xmlns:asp=&quot;#unknown&quot;&amp;gt;&amp;lt;/asp:textbox&amp;gt;&lt;br /&gt;
&amp;lt;ajaxtoolkit:calendarextender id=&quot;TextBox1_CalendarExtender&quot;
runat=&quot;server&quot; onclienthidden=&quot;onCalendarHidden&quot;
xmlns:ajaxtoolkit=&quot;#unknown&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;OnClientShown=&quot;onCalendarShown&quot;
Format=&quot;yyyy&quot; BehaviorID=&quot;calendar1&quot;&amp;nbsp; TargetControlID=&quot;TextBox1&quot;&amp;gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://armoe.blogspot.com/feeds/8153869845909090700/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='http://armoe.blogspot.com/2016/06/how-allow-user-to-only-view-and-select.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/8153869845909090700'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/8153869845909090700'/><link rel='alternate' type='text/html' href='http://armoe.blogspot.com/2016/06/how-allow-user-to-only-view-and-select.html' title='How allow user to only view and select years with ajax calendar?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02277756216508959449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2065822655831694480.post-6598829376120268595</id><published>2016-06-17T15:33:00.002-07:00</published><updated>2016-06-17T15:33:59.873-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Sharp"/><category scheme="http://www.blogger.com/atom/ns#" term="Solved Problem"/><title type='text'>How do I loop through a date range?</title><content type='html'>&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Well, you&#39;ll need to
loop over them one way or the other. I prefer defining a method like this:&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;b&gt;public
IEnumerable&amp;lt;DateTime&amp;gt; EachDay(DateTime from, DateTime
thru)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; for(var day = from.Date; day.Date
&amp;lt;= thru.Date; day = day.AddDays(1))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; yield return day;&lt;br /&gt;
}&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
Then you can use it
like this:&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;b&gt;foreach (DateTime
day in EachDay(StartDate, EndDate))&lt;/b&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; // print it or whatever&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
In this manner you
could hit every other day, every third day, only weekdays, etc. For example, to
return every third day starting with the &quot;start&quot; date, you could just
call AddDays(3) in the loop instead of AddDays(1).&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin: 0in;&quot;&gt;
&lt;b&gt;Source:stackoverflow.com&lt;/b&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://armoe.blogspot.com/feeds/6598829376120268595/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='http://armoe.blogspot.com/2016/06/how-do-i-loop-through-date-range.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/6598829376120268595'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/6598829376120268595'/><link rel='alternate' type='text/html' href='http://armoe.blogspot.com/2016/06/how-do-i-loop-through-date-range.html' title='How do I loop through a date range?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02277756216508959449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2065822655831694480.post-1530452239317543063</id><published>2016-06-17T15:28:00.002-07:00</published><updated>2016-06-17T15:29:30.514-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="English Tutorial"/><category scheme="http://www.blogger.com/atom/ns#" term="Sharepoint"/><category scheme="http://www.blogger.com/atom/ns#" term="Solved Problem"/><title type='text'>Error &quot;String was not recognized as a valid Boolean&quot; at PeopleEditor AKA PeoplePicker in custom layout pages Sharepoint 2010</title><content type='html'>&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin-left: .375in; margin: 0in;&quot;&gt;
If
you are using PeopleEditor AKA PeoplePicker in custom layout pages and have
installed SharePoint 2010 SP1 and the June 2011 CU you may experience problems
if your application page performs a postback.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin-left: .375in; margin: 0in;&quot;&gt;
If
you have filled your people editor control with a value before a postback is
triggered, it will stop functioning as an actual picker and if you perform
another postback on the page you will get an errormessage: “String was not
recognized as a valid Boolean”.&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin-left: .375in; margin: 0in;&quot;&gt;
The
reason seems to be that a lot of span tags are not regenerated after the first
postback. &lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin-left: .375in; margin: 0in;&quot;&gt;
The
only descent fix so far seems to be to validate the PeopleEditor control in the
page OnLoad event:&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin-left: .375in; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Calibri; font-size: 11.0pt; margin-left: .375in; margin: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ol style=&quot;direction: ltr; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; margin-bottom: 0in; margin-left: 0.375in; margin-top: 0in; unicode-bidi: embed;&quot; type=&quot;1&quot;&gt;
&lt;li style=&quot;color: blue; margin-bottom: 0; margin-top: 0; vertical-align: middle;&quot; value=&quot;1&quot;&gt;&lt;span style=&quot;background: white; font-size: 10pt;&quot;&gt;protected&lt;/span&gt;&lt;span style=&quot;background: white; color: black; font-size: 10pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background: white; font-size: 10pt;&quot;&gt;override&lt;/span&gt;&lt;span style=&quot;background: white; color: black; font-size: 10pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background: white; font-size: 10pt;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;background: white; color: black; font-size: 10pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background: white; color: darkcyan; font-size: 10pt;&quot;&gt;OnLoad&lt;/span&gt;&lt;span style=&quot;background: white; color: black; font-size: 10pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;background: white; color: darkblue; font-size: 10pt;&quot;&gt;EventArgs&lt;/span&gt;&lt;span style=&quot;background: white; color: black; font-size: 10pt;&quot;&gt; e)&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;ol style=&quot;direction: ltr; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; margin-bottom: 0in; margin-left: 0.375in; margin-top: 0in; unicode-bidi: embed;&quot; type=&quot;1&quot;&gt;
&lt;li style=&quot;margin-bottom: 0px; margin-top: 0px; vertical-align: middle;&quot; value=&quot;2&quot;&gt;&lt;span style=&quot;background: rgb(243, 243, 243); font-size: 10pt;&quot;&gt;{&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0px; margin-top: 0px; vertical-align: middle;&quot;&gt;&lt;span style=&quot;background: white; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background: white; color: blue; font-size: 10pt;&quot;&gt;base&lt;/span&gt;&lt;span style=&quot;background: white; font-size: 10pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;background: white; color: darkcyan; font-size: 10pt;&quot;&gt;OnLoad&lt;/span&gt;&lt;span style=&quot;background: white; font-size: 10pt;&quot;&gt;(e);&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0px; margin-top: 0px; vertical-align: middle;&quot;&gt;&lt;span style=&quot;background: rgb(243, 243, 243); font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background: rgb(243 , 243 , 243); color: blue; font-size: 10pt;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;background: rgb(243, 243, 243); font-size: 10pt;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;background: rgb(243 , 243 , 243); color: purple; font-size: 10pt;&quot;&gt;IsPostBack&lt;/span&gt;&lt;span style=&quot;background: rgb(243, 243, 243); font-size: 10pt;&quot;&gt;)&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0px; margin-top: 0px; vertical-align: middle;&quot;&gt;&lt;span style=&quot;background: white; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0px; margin-top: 0px; vertical-align: middle;&quot;&gt;&lt;span style=&quot;background: rgb(243, 243, 243); font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background: rgb(243 , 243 , 243); color: purple; font-size: 10pt;&quot;&gt;yourPeopleEditor&lt;/span&gt;&lt;span style=&quot;background: rgb(243, 243, 243); font-size: 10pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;background: rgb(243 , 243 , 243); color: darkcyan; font-size: 10pt;&quot;&gt;Validate&lt;/span&gt;&lt;span style=&quot;background: rgb(243, 243, 243); font-size: 10pt;&quot;&gt;();&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0px; margin-top: 0px; vertical-align: middle;&quot;&gt;&lt;span style=&quot;background: white; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0px; margin-top: 0px; vertical-align: middle;&quot;&gt;&lt;span style=&quot;background: rgb(243, 243, 243); font-size: 10pt;&quot;&gt;}&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot;;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot;;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;Source:&lt;/span&gt;&lt;/span&gt;ogarshol.blogspot.com&lt;/b&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://armoe.blogspot.com/feeds/1530452239317543063/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='http://armoe.blogspot.com/2016/06/string-was-not-recognized-as-valid.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/1530452239317543063'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/1530452239317543063'/><link rel='alternate' type='text/html' href='http://armoe.blogspot.com/2016/06/string-was-not-recognized-as-valid.html' title='Error &quot;String was not recognized as a valid Boolean&quot; at PeopleEditor AKA PeoplePicker in custom layout pages Sharepoint 2010'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02277756216508959449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2065822655831694480.post-8355441225683484574</id><published>2016-06-17T14:56:00.002-07:00</published><updated>2016-06-17T15:23:56.578-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="Tutorial Bhs Indo"/><title type='text'>Apa itu Callback , Asyncronous dan Synchronous pada javascript ?</title><content type='html'>&lt;h4 class=&quot;graf--h4 graf-after--h3&quot; id=&quot;0835&quot; name=&quot;0835&quot; style=&quot;background-color: white; color: rgba(0, 0, 0, 0.439216); font-family: medium-content-sans-serif-font, &amp;quot;Lucida Grande&amp;quot;, &amp;quot;Lucida Sans Unicode&amp;quot;, &amp;quot;Lucida Sans&amp;quot;, Geneva, Arial, sans-serif; font-size: 28px; font-weight: 300; letter-spacing: -0.022em; line-height: 1.22; margin: 1px 0px 0px -1.75px;&quot;&gt;
Penjelasan sederhana tentang bagaimana Asyncronous dan Synchronous bekerja pada javascript&lt;/h4&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimTttqiMVWj_1Z_wAHWkOVk4Z2JCKnck6xylMXPtMfQlehj9aFqETdIlLWPoXzCowYFriyE8nJZDcU77UVUQYysapFcgFmk4_FTPTx3MPQ1RYpj7AlQRdPV4d52HA3hCq3yFRCHhiPvbRw/s1600/i-love-javascript.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimTttqiMVWj_1Z_wAHWkOVk4Z2JCKnck6xylMXPtMfQlehj9aFqETdIlLWPoXzCowYFriyE8nJZDcU77UVUQYysapFcgFmk4_FTPTx3MPQ1RYpj7AlQRdPV4d52HA3hCq3yFRCHhiPvbRw/s320/i-love-javascript.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 class=&quot;graf--h3 graf-after--figure&quot; id=&quot;3062&quot; name=&quot;3062&quot; style=&quot;background-color: white; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, &amp;quot;Lucida Grande&amp;quot;, &amp;quot;Lucida Sans Unicode&amp;quot;, &amp;quot;Lucida Sans&amp;quot;, Geneva, Arial, sans-serif; font-size: 36px; letter-spacing: -0.02em; line-height: 1.15; margin: 65px 0px 0px -2.25px;&quot;&gt;
Perkenalkan Paijo&amp;nbsp;!&lt;/h3&gt;
&lt;div class=&quot;graf--p graf-after--h3&quot; id=&quot;a385&quot; name=&quot;a385&quot; style=&quot;background-color: white; color: rgba(0, 0, 0, 0.8); font-family: medium-content-serif-font, Georgia, Cambria, &amp;quot;Times New Roman&amp;quot;, Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 1.58; margin-top: 12px;&quot;&gt;
Beranganlah saja kamu adalah seorang bos yang memiliki satu asisten yang bernama Paijo!&lt;/div&gt;
&lt;div class=&quot;graf--p graf-after--p&quot; id=&quot;40b7&quot; name=&quot;40b7&quot; style=&quot;background-color: white; color: rgba(0, 0, 0, 0.8); font-family: medium-content-serif-font, Georgia, Cambria, &amp;quot;Times New Roman&amp;quot;, Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 1.58; margin-top: 29px;&quot;&gt;
Pada suatu hari kamu menyuruh Paijo untuk melakukan beberapa tugas:&lt;/div&gt;
&lt;ol class=&quot;postList&quot; style=&quot;background-color: white; color: rgba(0, 0, 0, 0.8); counter-reset: post 0; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif; font-size: 18px; line-height: 25.2px; list-style: none none; margin: 29px 0px 0px; padding: 0px;&quot;&gt;
&lt;li class=&quot;graf--li graf-after--p&quot; id=&quot;ceb4&quot; name=&quot;ceb4&quot; style=&quot;font-family: medium-content-serif-font, Georgia, Cambria, &amp;quot;Times New Roman&amp;quot;, Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 1.58; margin-bottom: 14px; margin-left: 30px;&quot;&gt;Membeli Gula&lt;/li&gt;
&lt;li class=&quot;graf--li graf-after--li&quot; id=&quot;bcb7&quot; name=&quot;bcb7&quot; style=&quot;font-family: medium-content-serif-font, Georgia, Cambria, &amp;quot;Times New Roman&amp;quot;, Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 1.58; margin-bottom: 14px; margin-left: 30px;&quot;&gt;Membeli Kopi&lt;/li&gt;
&lt;li class=&quot;graf--li graf-after--li&quot; id=&quot;821e&quot; name=&quot;821e&quot; style=&quot;font-family: medium-content-serif-font, Georgia, Cambria, &amp;quot;Times New Roman&amp;quot;, Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 1.58; margin-bottom: 14px; margin-left: 30px;&quot;&gt;Memasak Air&lt;/li&gt;
&lt;li class=&quot;graf--li graf-after--li&quot; id=&quot;b2d4&quot; name=&quot;b2d4&quot; style=&quot;font-family: medium-content-serif-font, Georgia, Cambria, &amp;quot;Times New Roman&amp;quot;, Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 1.58; margin-bottom: 14px; margin-left: 30px;&quot;&gt;Mengambil gelas&lt;/li&gt;
&lt;li class=&quot;graf--li graf-after--li&quot; id=&quot;b412&quot; name=&quot;b412&quot; style=&quot;font-family: medium-content-serif-font, Georgia, Cambria, &amp;quot;Times New Roman&amp;quot;, Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 1.58; margin-bottom: 14px; margin-left: 30px;&quot;&gt;Menuangkan Kopi secukupnya&lt;/li&gt;
&lt;li class=&quot;graf--li graf-after--li&quot; id=&quot;c73b&quot; name=&quot;c73b&quot; style=&quot;font-family: medium-content-serif-font, Georgia, Cambria, &amp;quot;Times New Roman&amp;quot;, Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 1.58; margin-bottom: 14px; margin-left: 30px;&quot;&gt;Menuangkan Gula secukupnya&lt;/li&gt;
&lt;li class=&quot;graf--li graf-after--li&quot; id=&quot;c083&quot; name=&quot;c083&quot; style=&quot;font-family: medium-content-serif-font, Georgia, Cambria, &amp;quot;Times New Roman&amp;quot;, Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 1.58; margin-bottom: 0px; margin-left: 30px;&quot;&gt;Dll&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graf--p graf-after--li&quot; id=&quot;af65&quot; name=&quot;af65&quot; style=&quot;background-color: white; color: rgba(0, 0, 0, 0.8); font-family: medium-content-serif-font, Georgia, Cambria, &amp;quot;Times New Roman&amp;quot;, Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 1.58; margin-top: 29px;&quot;&gt;
Karena kamu hanya memiliki satu pembantu maka tugas yang kamu berikan diatas hanya dilakukan oleh paijo, maka kita adalah S&lt;span class=&quot;markup--strong markup--p-strong&quot; style=&quot;font-weight: 700;&quot;&gt;ingle Threaded&amp;nbsp;&lt;/span&gt;tapi jika kita memiliki lebih dari satu pembantu maka kita disebut&amp;nbsp;&lt;span class=&quot;markup--strong markup--p-strong&quot; style=&quot;font-weight: 700;&quot;&gt;Multi Threaded.&lt;/span&gt;&lt;/div&gt;
&lt;blockquote class=&quot;graf--pullquote pullquote graf-after--p&quot; id=&quot;86bb&quot; name=&quot;86bb&quot; style=&quot;background-color: white; border: none; color: rgba(0, 0, 0, 0.6); font-family: medium-content-slab-serif-font, Georgia, Cambria, &amp;quot;Times New Roman&amp;quot;, Times, serif; font-size: 28px; font-style: italic; letter-spacing: -0.014em; line-height: 1.48; margin: 55px 0px 0px -1.75px; padding: 0px 0px 0px 50px;&quot;&gt;
Javascript adalah bahasa pemograman yang Single Threaded&lt;/blockquote&gt;
&lt;h3 class=&quot;graf--h3 graf-after--pullquote&quot; id=&quot;2235&quot; name=&quot;2235&quot; style=&quot;background-color: white; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, &amp;quot;Lucida Grande&amp;quot;, &amp;quot;Lucida Sans Unicode&amp;quot;, &amp;quot;Lucida Sans&amp;quot;, Geneva, Arial, sans-serif; font-size: 36px; letter-spacing: -0.02em; line-height: 1.15; margin: 53px 0px 0px -2.25px;&quot;&gt;
Single Threaded&lt;/h3&gt;
&lt;div class=&quot;graf--p graf-after--h3&quot; id=&quot;a410&quot; name=&quot;a410&quot; style=&quot;background-color: white; color: rgba(0, 0, 0, 0.8); font-family: medium-content-serif-font, Georgia, Cambria, &amp;quot;Times New Roman&amp;quot;, Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 1.58; margin-top: 12px;&quot;&gt;
Karena Javascript adalah Single Threaded maka javascript hanya dapat menghandle satu tugas pada satu waktu dan dapat melanjutkan tugas yang lain ketika tugas sebelumnya telah selesai, hal ini disebut dengan&amp;nbsp;&lt;span class=&quot;markup--strong markup--p-strong&quot; style=&quot;font-weight: 700;&quot;&gt;Blocking&lt;/span&gt;&lt;/div&gt;
&lt;h4 class=&quot;graf--h4 graf-after--p&quot; id=&quot;a95d&quot; name=&quot;a95d&quot; style=&quot;background-color: white; color: rgba(0, 0, 0, 0.439216); font-family: medium-content-sans-serif-font, &amp;quot;Lucida Grande&amp;quot;, &amp;quot;Lucida Sans Unicode&amp;quot;, &amp;quot;Lucida Sans&amp;quot;, Geneva, Arial, sans-serif; font-size: 28px; font-weight: 300; letter-spacing: -0.022em; line-height: 1.22; margin: 30px 0px 0px -1.75px;&quot;&gt;
Masalah?&lt;/h4&gt;
&lt;div class=&quot;graf--p graf-after--h4&quot; id=&quot;ff21&quot; name=&quot;ff21&quot; style=&quot;background-color: white; color: rgba(0, 0, 0, 0.8); font-family: medium-content-serif-font, Georgia, Cambria, &amp;quot;Times New Roman&amp;quot;, Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 1.58; margin-top: 10px;&quot;&gt;
Masalah yang terdapat pada Single Threaded adalah ia memakan banyak waktu tidak berguna yaitu menunggu sebuah proses selesai untuk mengerjakan proses yang lain, padahal kita dapat menunggu proses yang belum selesai sambil mengerjakan proses yang lain bukan&amp;nbsp;?&lt;/div&gt;
&lt;blockquote class=&quot;graf--pullquote pullquote graf-after--p&quot; id=&quot;bee3&quot; name=&quot;bee3&quot; style=&quot;background-color: white; border: none; color: rgba(0, 0, 0, 0.6); font-family: medium-content-slab-serif-font, Georgia, Cambria, &amp;quot;Times New Roman&amp;quot;, Times, serif; font-size: 28px; font-style: italic; letter-spacing: -0.014em; line-height: 1.48; margin: 55px 0px 0px -1.75px; padding: 0px 0px 0px 50px;&quot;&gt;
Kemudian lahirlah Asynchronous&amp;nbsp;:)&lt;/blockquote&gt;
&lt;h3 class=&quot;graf--h3 graf-after--pullquote&quot; id=&quot;1877&quot; name=&quot;1877&quot; style=&quot;background-color: white; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, &amp;quot;Lucida Grande&amp;quot;, &amp;quot;Lucida Sans Unicode&amp;quot;, &amp;quot;Lucida Sans&amp;quot;, Geneva, Arial, sans-serif; font-size: 36px; letter-spacing: -0.02em; line-height: 1.15; margin: 53px 0px 0px -2.25px;&quot;&gt;
Asynchronous dan Event Loop&lt;/h3&gt;
&lt;div class=&quot;graf--p graf-after--h3&quot; id=&quot;6b4d&quot; name=&quot;6b4d&quot; style=&quot;background-color: white; color: rgba(0, 0, 0, 0.8); font-family: medium-content-serif-font, Georgia, Cambria, &amp;quot;Times New Roman&amp;quot;, Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 1.58; margin-top: 12px;&quot;&gt;
Saat paijo memasak air tentu memakan cukup banyak waktu hingga air yang ia masak mendidih, maka dari itu selama menunggu ia dapat mengerjakan tugas yang lain seperti menyiapkan gelas dan menuangkan kopi serta gula. inilah yang disebut asynchronous.&lt;/div&gt;
&lt;div class=&quot;graf--p graf-after--p&quot; id=&quot;7bc0&quot; name=&quot;7bc0&quot; style=&quot;background-color: white; color: rgba(0, 0, 0, 0.8); font-family: medium-content-serif-font, Georgia, Cambria, &amp;quot;Times New Roman&amp;quot;, Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 1.58; margin-top: 29px;&quot;&gt;
Sementara itu, setelah air mendidih tentu Paijo harus mematikan kompor dan menuang air yang telah mendidih tadi, maka dari itu Paijo harus mengecek air yang ia masak setiap beberapa saat! maka tugas ini pada javascript disebut&lt;span class=&quot;markup--strong markup--p-strong&quot; style=&quot;font-weight: 700;&quot;&gt;Event Loop&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;graf--p graf-after--p&quot; id=&quot;d995&quot; name=&quot;d995&quot; style=&quot;background-color: white; color: rgba(0, 0, 0, 0.8); font-family: medium-content-serif-font, Georgia, Cambria, &amp;quot;Times New Roman&amp;quot;, Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 1.58; margin-top: 29px;&quot;&gt;
Asynchronous juga membuat background task yang disebut Event Loop untuk mengecek dan mengatur proses yang telah selesai.&lt;/div&gt;
&lt;h3 class=&quot;graf--h3 graf-after--p&quot; id=&quot;85f3&quot; name=&quot;85f3&quot; style=&quot;background-color: white; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, &amp;quot;Lucida Grande&amp;quot;, &amp;quot;Lucida Sans Unicode&amp;quot;, &amp;quot;Lucida Sans&amp;quot;, Geneva, Arial, sans-serif; font-size: 36px; letter-spacing: -0.02em; line-height: 1.15; margin: 56px 0px 0px -2.25px;&quot;&gt;
Callback&lt;/h3&gt;
&lt;div class=&quot;graf--p graf-after--h3&quot; id=&quot;9cde&quot; name=&quot;9cde&quot; style=&quot;background-color: white; color: rgba(0, 0, 0, 0.8); font-family: medium-content-serif-font, Georgia, Cambria, &amp;quot;Times New Roman&amp;quot;, Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 1.58; margin-top: 12px;&quot;&gt;
Secara default Javascript melakukan tugas secara Asynchronous yang berarti setiap tugas tidak dijalankan secara berurutan namun dikerjakan berdasarkan yang tercepat.&lt;/div&gt;
&lt;div class=&quot;graf--p graf-after--p&quot; id=&quot;3f16&quot; name=&quot;3f16&quot; style=&quot;background-color: white; color: rgba(0, 0, 0, 0.8); font-family: medium-content-serif-font, Georgia, Cambria, &amp;quot;Times New Roman&amp;quot;, Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 1.58; margin-top: 29px;&quot;&gt;
Masalahnya adalah jika terjadi pada contoh kasus Paijo yang membuat kopi, dimana proses memasak air membutuhkan waktu cukup lama dibanding yang lain maka akan terjadi proses mengaduk kopi padahal air belum mendidih, tentu hal ini mustahil dan dalam program akan terjadi error.&lt;/div&gt;
&lt;div class=&quot;graf--p graf-after--p&quot; id=&quot;6c07&quot; name=&quot;6c07&quot; style=&quot;background-color: white; color: rgba(0, 0, 0, 0.8); font-family: medium-content-serif-font, Georgia, Cambria, &amp;quot;Times New Roman&amp;quot;, Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 1.58; margin-top: 29px;&quot;&gt;
Jadi kita tetap harus mengurutkan beberapa pekerjaan atau membuat Teknik Synchronous.&lt;/div&gt;
&lt;blockquote class=&quot;graf--pullquote pullquote graf-after--p&quot; id=&quot;d67d&quot; name=&quot;d67d&quot; style=&quot;background-color: white; border: none; color: rgba(0, 0, 0, 0.6); font-family: medium-content-slab-serif-font, Georgia, Cambria, &amp;quot;Times New Roman&amp;quot;, Times, serif; font-size: 28px; font-style: italic; letter-spacing: -0.014em; line-height: 1.48; margin: 55px 0px 0px -1.75px; padding: 0px 0px 0px 50px;&quot;&gt;
Callback adalah teknik memasangkan beberapa tugas agar berjalan berurutan&lt;/blockquote&gt;
&lt;br /&gt;
&lt;figure class=&quot;graf--figure graf-after--pullquote&quot; id=&quot;b9fc&quot; name=&quot;b9fc&quot; style=&quot;background-color: white; box-sizing: border-box; clear: both; color: rgba(0, 0, 0, 0.8); font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif; font-size: 18px; line-height: 25.2px; margin: 68px 0px 0px; outline: 0px; position: relative;&quot;&gt;&lt;div class=&quot;aspectRatioPlaceholder is-locked&quot; style=&quot;margin: 0px auto; max-height: 137px; max-width: 700px; position: relative; width: 700px;&quot;&gt;
&lt;div class=&quot;aspectRatioPlaceholder-fill&quot; style=&quot;padding-bottom: 137.188px;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded&quot; data-action-value=&quot;1*0YUZlFLAraDog6vVYHwlKw.png&quot; data-action=&quot;zoom&quot; data-height=&quot;175&quot; data-image-id=&quot;1*0YUZlFLAraDog6vVYHwlKw.png&quot; data-scroll=&quot;native&quot; data-width=&quot;894&quot; style=&quot;background: rgba(0, 0, 0, 0); box-sizing: border-box; cursor: zoom-in; height: 137px; left: 0px; margin: auto; max-width: 100%; position: absolute; top: 0px; transition: background 0.2s; width: 700px;&quot;&gt;
&lt;canvas class=&quot;progressiveMedia-canvas js-progressiveMedia-canvas&quot; height=&quot;12&quot; style=&quot;backface-visibility: hidden; box-sizing: border-box; display: block; height: 137px; left: 0px; margin: auto; opacity: 0; position: absolute; top: 0px; transition: visibility 0s linear 0.5s, opacity 0.1s 0.4s; vertical-align: baseline; visibility: hidden; width: 700px;&quot; width=&quot;75&quot;&gt;&lt;/canvas&gt;&lt;img class=&quot;progressiveMedia-image js-progressiveMedia-image&quot; data-src=&quot;https://cdn-images-1.medium.com/max/800/1*0YUZlFLAraDog6vVYHwlKw.png&quot; src=&quot;https://cdn-images-1.medium.com/max/800/1*0YUZlFLAraDog6vVYHwlKw.png&quot; style=&quot;backface-visibility: hidden; border: 0px; box-sizing: border-box; display: block; height: 137px; left: 0px; margin: auto; opacity: 1; position: absolute; top: 0px; transition: visibility 0s linear 0s, opacity 0.4s 0s; visibility: visible; width: 700px; z-index: 100;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/figure&gt;&lt;br /&gt;
&lt;div class=&quot;graf--p graf-after--figure&quot; id=&quot;434c&quot; name=&quot;434c&quot; style=&quot;background-color: white; color: rgba(0, 0, 0, 0.8); font-family: medium-content-serif-font, Georgia, Cambria, &amp;quot;Times New Roman&amp;quot;, Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 1.58; margin-top: 38px;&quot;&gt;
Berikut adalah contoh penggunaan callback pada function jQuery.get(link, callback);&lt;/div&gt;
&lt;div class=&quot;graf--p graf-after--p&quot; id=&quot;f6b3&quot; name=&quot;f6b3&quot; style=&quot;background-color: white; color: rgba(0, 0, 0, 0.8); font-family: medium-content-serif-font, Georgia, Cambria, &amp;quot;Times New Roman&amp;quot;, Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 1.58; margin-top: 29px;&quot;&gt;
console.log(data) hanya akan dijalankan ketika proses $.get telah selesai dan telah memberikan data yang kita request.&lt;/div&gt;
&lt;br /&gt;
&lt;figure class=&quot;graf--figure graf-after--p&quot; id=&quot;de97&quot; name=&quot;de97&quot; style=&quot;background-color: white; box-sizing: border-box; clear: both; color: rgba(0, 0, 0, 0.8); font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif; font-size: 18px; line-height: 25.2px; margin: 43px 0px 0px; outline: 0px; position: relative;&quot;&gt;&lt;div class=&quot;aspectRatioPlaceholder is-locked&quot; style=&quot;margin: 0px auto; max-height: 278px; max-width: 671px; position: relative; width: 671px;&quot;&gt;
&lt;div class=&quot;aspectRatioPlaceholder-fill&quot; style=&quot;padding-bottom: 277.781px;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded&quot; data-height=&quot;278&quot; data-image-id=&quot;1*qSskmAT9Gtyf6R5_pzpeMg.png&quot; data-scroll=&quot;native&quot; data-width=&quot;671&quot; style=&quot;background: rgba(0, 0, 0, 0); box-sizing: border-box; height: 277.781px; left: 0px; margin: auto; max-width: 100%; position: absolute; top: 0px; transition: background 0.2s; width: 671px;&quot;&gt;
&lt;canvas class=&quot;progressiveMedia-canvas js-progressiveMedia-canvas&quot; height=&quot;30&quot; style=&quot;backface-visibility: hidden; box-sizing: border-box; display: block; height: 277.781px; left: 0px; margin: auto; opacity: 0; position: absolute; top: 0px; transition: visibility 0s linear 0.5s, opacity 0.1s 0.4s; vertical-align: baseline; visibility: hidden; width: 671px;&quot; width=&quot;75&quot;&gt;&lt;/canvas&gt;&lt;img class=&quot;progressiveMedia-image js-progressiveMedia-image&quot; data-src=&quot;https://cdn-images-1.medium.com/max/800/1*qSskmAT9Gtyf6R5_pzpeMg.png&quot; src=&quot;https://cdn-images-1.medium.com/max/800/1*qSskmAT9Gtyf6R5_pzpeMg.png&quot; style=&quot;backface-visibility: hidden; border: 0px; box-sizing: border-box; display: block; height: 277.781px; left: 0px; margin: auto; opacity: 1; position: absolute; top: 0px; transition: visibility 0s linear 0s, opacity 0.4s 0s; visibility: visible; width: 671px; z-index: 100;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/figure&gt;&lt;br /&gt;
&lt;h4 class=&quot;graf--h4 graf-after--figure&quot; id=&quot;8249&quot; name=&quot;8249&quot; style=&quot;background-color: white; color: rgba(0, 0, 0, 0.439216); font-family: medium-content-sans-serif-font, &amp;quot;Lucida Grande&amp;quot;, &amp;quot;Lucida Sans Unicode&amp;quot;, &amp;quot;Lucida Sans&amp;quot;, Geneva, Arial, sans-serif; font-size: 28px; font-weight: 300; letter-spacing: -0.022em; line-height: 1.22; margin: 39px 0px 0px -1.75px;&quot;&gt;
Mari kita buktikan bahwa Callback itu perlu karena Javascript adalah Asynchronous!&lt;/h4&gt;
&lt;br /&gt;
&lt;figure class=&quot;graf--figure graf-after--h4&quot; id=&quot;5744&quot; name=&quot;5744&quot; style=&quot;background-color: white; box-sizing: border-box; clear: both; color: rgba(0, 0, 0, 0.8); font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif; font-size: 18px; line-height: 25.2px; margin: 44px 0px 0px; outline: 0px; position: relative;&quot;&gt;&lt;div class=&quot;aspectRatioPlaceholder is-locked&quot; style=&quot;margin: 0px auto; max-height: 255px; max-width: 700px; position: relative; width: 700px;&quot;&gt;
&lt;div class=&quot;aspectRatioPlaceholder-fill&quot; style=&quot;padding-bottom: 255.5px;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded&quot; data-action-value=&quot;1*soFbRiAo2Ze49_0oa8GLtQ.png&quot; data-action=&quot;zoom&quot; data-height=&quot;342&quot; data-image-id=&quot;1*soFbRiAo2Ze49_0oa8GLtQ.png&quot; data-scroll=&quot;native&quot; data-width=&quot;938&quot; style=&quot;background: rgba(0, 0, 0, 0); box-sizing: border-box; cursor: zoom-in; height: 255px; left: 0px; margin: auto; max-width: 100%; position: absolute; top: 0px; transition: background 0.2s; width: 700px;&quot;&gt;
&lt;canvas class=&quot;progressiveMedia-canvas js-progressiveMedia-canvas&quot; height=&quot;25&quot; style=&quot;backface-visibility: hidden; box-sizing: border-box; display: block; height: 255px; left: 0px; margin: auto; opacity: 0; position: absolute; top: 0px; transition: visibility 0s linear 0.5s, opacity 0.1s 0.4s; vertical-align: baseline; visibility: hidden; width: 700px;&quot; width=&quot;75&quot;&gt;&lt;/canvas&gt;&lt;img class=&quot;progressiveMedia-image js-progressiveMedia-image&quot; data-src=&quot;https://cdn-images-1.medium.com/max/800/1*soFbRiAo2Ze49_0oa8GLtQ.png&quot; src=&quot;https://cdn-images-1.medium.com/max/800/1*soFbRiAo2Ze49_0oa8GLtQ.png&quot; style=&quot;backface-visibility: hidden; border: 0px; box-sizing: border-box; display: block; height: 255px; left: 0px; margin: auto; opacity: 1; position: absolute; top: 0px; transition: visibility 0s linear 0s, opacity 0.4s 0s; visibility: visible; width: 700px; z-index: 100;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/figure&gt;&lt;br /&gt;
&lt;div class=&quot;graf--p graf-after--figure&quot; id=&quot;c50d&quot; name=&quot;c50d&quot; style=&quot;background-color: white; color: rgba(0, 0, 0, 0.8); font-family: medium-content-serif-font, Georgia, Cambria, &amp;quot;Times New Roman&amp;quot;, Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 1.58; margin-top: 38px;&quot;&gt;
Code diatas membuktikan bahwa Javascript asynhcronous karena meski&lt;span class=&quot;markup--strong markup--p-strong&quot; style=&quot;font-weight: 700;&quot;&gt;console.log()&lt;/span&gt;&amp;nbsp;berada di akhir line, dia akan dijalankan terlebih dahulu karena proses&amp;nbsp;&lt;span class=&quot;markup--strong markup--p-strong&quot; style=&quot;font-weight: 700;&quot;&gt;$.get()&lt;/span&gt;&amp;nbsp;memakan lebih banyak waktu ketimbang console.log() dan hasilnya akan&amp;nbsp;&lt;span class=&quot;markup--strong markup--p-strong&quot; style=&quot;font-weight: 700;&quot;&gt;undefined&amp;nbsp;&lt;/span&gt;karena&amp;nbsp;&lt;span class=&quot;markup--strong markup--p-strong&quot; style=&quot;font-weight: 700;&quot;&gt;result = data&lt;/span&gt;&amp;nbsp;dijalankan setelah console.log().&lt;/div&gt;
&lt;br /&gt;
&lt;figure class=&quot;graf--figure graf-after--p&quot; id=&quot;ec9e&quot; name=&quot;ec9e&quot; style=&quot;background-color: white; box-sizing: border-box; clear: both; color: rgba(0, 0, 0, 0.8); font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif; font-size: 18px; line-height: 25.2px; margin: 43px 0px 0px; outline: 0px; position: relative;&quot;&gt;&lt;div class=&quot;aspectRatioPlaceholder is-locked&quot; style=&quot;margin: 0px auto; max-height: 174px; max-width: 374px; position: relative; width: 374px;&quot;&gt;
&lt;div class=&quot;aspectRatioPlaceholder-fill&quot; style=&quot;padding-bottom: 173.906px;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded&quot; data-height=&quot;174&quot; data-image-id=&quot;1*6IDGgO5mjlSTi0HIsDkSeQ.png&quot; data-scroll=&quot;native&quot; data-width=&quot;374&quot; style=&quot;background: rgba(0, 0, 0, 0); box-sizing: border-box; height: 173.906px; left: 0px; margin: auto; max-width: 100%; position: absolute; top: 0px; transition: background 0.2s; width: 374px;&quot;&gt;
&lt;canvas class=&quot;progressiveMedia-canvas js-progressiveMedia-canvas&quot; height=&quot;32&quot; style=&quot;backface-visibility: hidden; box-sizing: border-box; display: block; height: 173.906px; left: 0px; margin: auto; opacity: 0; position: absolute; top: 0px; transition: visibility 0s linear 0.5s, opacity 0.1s 0.4s; vertical-align: baseline; visibility: hidden; width: 374px;&quot; width=&quot;75&quot;&gt;&lt;/canvas&gt;&lt;img class=&quot;progressiveMedia-image js-progressiveMedia-image&quot; data-src=&quot;https://cdn-images-1.medium.com/max/800/1*6IDGgO5mjlSTi0HIsDkSeQ.png&quot; src=&quot;https://cdn-images-1.medium.com/max/800/1*6IDGgO5mjlSTi0HIsDkSeQ.png&quot; style=&quot;backface-visibility: hidden; border: 0px; box-sizing: border-box; display: block; height: 173.906px; left: 0px; margin: auto; opacity: 1; position: absolute; top: 0px; transition: visibility 0s linear 0s, opacity 0.4s 0s; visibility: visible; width: 374px; z-index: 100;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/figure&gt;&lt;br /&gt;
&lt;div class=&quot;graf--p graf-after--figure&quot; id=&quot;0793&quot; name=&quot;0793&quot; style=&quot;background-color: white; color: rgba(0, 0, 0, 0.8); font-family: medium-content-serif-font, Georgia, Cambria, &amp;quot;Times New Roman&amp;quot;, Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 1.58; margin-top: 38px;&quot;&gt;
Sekali lagi Callback digunakan untuk mengurutkan proses agar tidak terjadi lagi kasus seperti menampilkan hasil padahal belum mendapatkan hasil.&lt;/div&gt;
&lt;blockquote class=&quot;graf--pullquote pullquote graf-after--p&quot; id=&quot;76c7&quot; name=&quot;76c7&quot; style=&quot;background-color: white; border: none; color: rgba(0, 0, 0, 0.6); font-family: medium-content-slab-serif-font, Georgia, Cambria, &amp;quot;Times New Roman&amp;quot;, Times, serif; font-size: 28px; font-style: italic; letter-spacing: -0.014em; line-height: 1.48; margin: 55px 0px 0px -1.75px; padding: 0px 0px 0px 50px;&quot;&gt;
Callback: Jalankan proses ini setelah proses itu selesai&lt;/blockquote&gt;
&lt;h3 class=&quot;graf--h3 graf-after--pullquote&quot; id=&quot;8c94&quot; name=&quot;8c94&quot; style=&quot;background-color: white; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, &amp;quot;Lucida Grande&amp;quot;, &amp;quot;Lucida Sans Unicode&amp;quot;, &amp;quot;Lucida Sans&amp;quot;, Geneva, Arial, sans-serif; font-size: 36px; letter-spacing: -0.02em; line-height: 1.15; margin: 53px 0px 0px -2.25px;&quot;&gt;
Kesimpulan&lt;/h3&gt;
&lt;div class=&quot;graf--p graf-after--h3&quot; id=&quot;9359&quot; name=&quot;9359&quot; style=&quot;background-color: white; color: rgba(0, 0, 0, 0.8); font-family: medium-content-serif-font, Georgia, Cambria, &amp;quot;Times New Roman&amp;quot;, Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 1.58; margin-top: 12px;&quot;&gt;
Javascript adalah bahasa Asynchronous namun terkadang kita juga butuh Synchronous agar tidak terjadi overlap process dan Callback adalah metode untuk melakukan Synchronous pada Asynchronous.&lt;/div&gt;
&lt;div class=&quot;graf--p graf-after--p graf--last&quot; id=&quot;7238&quot; name=&quot;7238&quot; style=&quot;background-color: white; color: rgba(0, 0, 0, 0.8); font-family: medium-content-serif-font, Georgia, Cambria, &amp;quot;Times New Roman&amp;quot;, Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 1.58; margin-top: 29px;&quot;&gt;
Semoga artikel ini dapat membantu kita semua memahami fundamental Javascript.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Sumber: ihavemind.com&lt;/b&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://armoe.blogspot.com/feeds/8355441225683484574/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='http://armoe.blogspot.com/2016/06/apa-itu-callback-asyncronous-dan.html#comment-form' title='1 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/8355441225683484574'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/8355441225683484574'/><link rel='alternate' type='text/html' href='http://armoe.blogspot.com/2016/06/apa-itu-callback-asyncronous-dan.html' title='Apa itu Callback , Asyncronous dan Synchronous pada javascript ?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02277756216508959449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimTttqiMVWj_1Z_wAHWkOVk4Z2JCKnck6xylMXPtMfQlehj9aFqETdIlLWPoXzCowYFriyE8nJZDcU77UVUQYysapFcgFmk4_FTPTx3MPQ1RYpj7AlQRdPV4d52HA3hCq3yFRCHhiPvbRw/s72-c/i-love-javascript.jpg" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2065822655831694480.post-146290791625903914</id><published>2014-03-22T13:16:00.002-07:00</published><updated>2016-06-17T15:23:56.567-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Sharepoint"/><category scheme="http://www.blogger.com/atom/ns#" term="Tutorial Bhs Indo"/><title type='text'>Validate atau filter column sesuai aturan penulisan Email di Sharepoint</title><content type='html'>Di bawah ini adalah cara untuk memvalidasi atau memfilter column pada sharepoint sehingga text yang di masukkan sesuai&amp;nbsp; dengan aturan penulisan atau ejaan. Misalnya : ahmad@gmail.com maka nilai dari validasi itu adalah benar dan jika text yang dimasukkan ahmad@gmail saja maka validasi akan bernilai salah dan akan muncul pesan &quot;ERROR&quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;em&gt;=(LEN(LEFT([Email],FIND(&quot;@&quot;,[Email])-1))&amp;gt;0)       &lt;br /&gt;+(LEN(RIGHT([Email],LEN([Email])-FIND(&quot;.&quot;,[Email],FIND(&quot;@&quot;,[Email]))))&amp;gt;0)        &lt;br /&gt;+(LEN(MID([Email],FIND(&quot;@&quot;,[Email])+1,FIND(&quot;.&quot;,[Email],FIND(&quot;@&quot;,[Email]))-FIND(&quot;@&quot;,[Email])-1))&amp;gt;0)        &lt;br /&gt;+(ISERROR(FIND(&quot; &quot;,[Email]))=TRUE)        &lt;br /&gt;=4&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtEeXFGO8WCoFGaYCOBhcB4BJMoORzpoiObMRnKdxkqe_A-IvFTbnXx-sOIChOFo8sN01rwts8TOcj7ndiGiHqkO35KCH2Xr91BOnLm_dR9JAH0h5H4hViMr6bx0MpC08ttgtkQgJ-Ft0m/s1600/validate+email.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;260&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtEeXFGO8WCoFGaYCOBhcB4BJMoORzpoiObMRnKdxkqe_A-IvFTbnXx-sOIChOFo8sN01rwts8TOcj7ndiGiHqkO35KCH2Xr91BOnLm_dR9JAH0h5H4hViMr6bx0MpC08ttgtkQgJ-Ft0m/s1600/validate+email.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;strong&gt;&lt;em&gt;&amp;nbsp;Selamat mencoba...&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://armoe.blogspot.com/feeds/146290791625903914/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='http://armoe.blogspot.com/2014/03/validate-atau-filter-column-sesuai.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/146290791625903914'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/146290791625903914'/><link rel='alternate' type='text/html' href='http://armoe.blogspot.com/2014/03/validate-atau-filter-column-sesuai.html' title='Validate atau filter column sesuai aturan penulisan Email di Sharepoint'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02277756216508959449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtEeXFGO8WCoFGaYCOBhcB4BJMoORzpoiObMRnKdxkqe_A-IvFTbnXx-sOIChOFo8sN01rwts8TOcj7ndiGiHqkO35KCH2Xr91BOnLm_dR9JAH0h5H4hViMr6bx0MpC08ttgtkQgJ-Ft0m/s72-c/validate+email.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2065822655831694480.post-7180417968398014836</id><published>2014-02-02T22:17:00.001-08:00</published><updated>2016-06-17T15:23:56.572-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Tutorial Bhs Indo"/><category scheme="http://www.blogger.com/atom/ns#" term="Tutorial Blog"/><title type='text'>Membuat Widget Berita Berjalan di Blog</title><content type='html'>&lt;a href=&quot;https://www.blogger.com/blogger.g?blogID=2065822655831694480&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;https://www.blogger.com/blogger.g?blogID=2065822655831694480&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;/a&gt;Banyak sudah artikel yang membahas mengenai newsticker ini di internet, misalnya dengan menambah efek marquee
 sehingga teks tersebut dapat berjalan, tapi kali ini saya akan 
menjelaskan cara memasang breking news dengan sentuhan jQuery sehingga 
hasilnya akan lebih menarik dan yang pasti dapat mempercatik blog anda.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://www.blogger.com/blogger.g?blogID=2065822655831694480&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-zronFFOUYdKKbTMbtOp_Ida5G0APkGeqq1t4zfWkg5ONZaNTV8AZSOKLiggqYwUmRMClY8zI7TWC6ZA8f5KGf3OjqEZCOAsccjj7WEauZQP8y4BeRRfXQvcMg963HdRkWruw9BlgPkQS/s1600/News+feed.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;28&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-zronFFOUYdKKbTMbtOp_Ida5G0APkGeqq1t4zfWkg5ONZaNTV8AZSOKLiggqYwUmRMClY8zI7TWC6ZA8f5KGf3OjqEZCOAsccjj7WEauZQP8y4BeRRfXQvcMg963HdRkWruw9BlgPkQS/s1600/News+feed.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;a href=&quot;https://www.blogger.com/blogger.g?blogID=2065822655831694480&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;Ternyata cara memasangnya sangat gampang sekali, dan jika Anda tertarik berikut ini langkah-langkah untuk membuatnya :&lt;br /&gt;
&lt;ol&gt;
&lt;a href=&quot;https://www.blogger.com/blogger.g?blogID=2065822655831694480&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;https://www.blogger.com/blogger.g?blogID=2065822655831694480&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;https://www.blogger.com/blogger.g?blogID=2065822655831694480&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;
&lt;li&gt;&amp;nbsp;Login  ke blogger dengan akun anda&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Kemudian klik  &lt;b&gt;Tata Letak&lt;/b&gt; &amp;gt; pilih &lt;b&gt;Edit  HTML&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Jangan lupa backup dulu template anda  dengan mengklik &lt;b&gt;Download  Template Lengkap&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Letakkan kode berikut di atas kode &lt;b style=&quot;color: #cc0000;&quot;&gt;]]&amp;gt;&amp;lt;/b:skin&amp;gt;&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: #c2c2c2; height: 200px; overflow: scroll; width: 100%;&quot;&gt;
/* News Ticker Wrapper &lt;br /&gt;
---------------------------------------------*/ &lt;br /&gt;
.newspic {background:#000 url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOxmjUnRMS7cKHDd76rL4fJd9RA8SqCCoFI4p2fMQBto6IWrLNoe1TqFt0yPlbcJ40EpkW592Qf0VgvSZ9oYiubhGSXQX9dTH9Qrx9wfgF2yI9siTp6CY8ChfItUofNHvAo0IDUDxO92E/s1600/news.gif) no-repeat top left;width:970px;margin:0 auto;padding:0 auto;height:32px;color:#fff;} &lt;br /&gt;
.news {width: 970px;margin:0 auto;padding:0 auto;line-height: 1.4em;text-align:left;font-family:Arial;font-size:11px;color:#fff;overflow:hidden;clear:both;} &lt;br /&gt;
.news a:link, .news a:visited{color:#fff;text-decoration:none;} &lt;br /&gt;
.news a:hover {color:#ddd;text-decoration:underline;}&amp;nbsp; &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Masih dalam dalam posisi Edit HTML. Sekarang letakkan kode berikut ini di atas kode &lt;b style=&quot;color: #cc0000;&quot;&gt;&amp;lt;/head&amp;gt;&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: #c2c2c2; height: 350px; overflow: scroll; width: 100%;&quot;&gt;
&amp;lt;script 
src=&#39;http://www.google.com/jsapi?key=ABQIAAAAUMsU2d40bO1-m8DeADFRexTdcQS31_Y0TkToW9tE1XWPEnv6YBSa1QfZaAr4GJ8-AZkWddpnW9Y0hA&#39;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;script type=&#39;text/javascript&#39;&amp;gt;&lt;br /&gt;
//&amp;lt;![CDATA[&lt;br /&gt;
var 
gfeedfetcher_loading_image=&quot;indicator.gif&quot;;google.load(&quot;feeds&quot;,&quot;1&quot;);function
 
gfeedfetcher(c,a,b){this.linktarget=b||&quot;&quot;;this.feedlabels=[];this.feedurls=[];this.feeds=[];this.feedsfetched=0;this.feedlimit=5;this.showoptions=&quot;&quot;;this.sortstring=&quot;date&quot;;document.write(&#39;&amp;lt;div
 id=&quot;&#39;+c+&#39;&quot; 
class=&quot;&#39;+a+&#39;&quot;&amp;gt;&amp;lt;/div&amp;gt;&#39;);this.feedcontainer=document.getElementById(c);this.itemcontainer=&quot;&amp;lt;li&amp;gt;&quot;}gfeedfetcher.prototype.addFeed=function(b,a){this.feedlabels[this.feedlabels.length]=b;this.feedurls[this.feedurls.length]=a};gfeedfetcher.prototype.filterfeed=function(b,a){this.feedlimit=b;if(typeof
 
a!=&quot;undefined&quot;){this.sortstring=a}};gfeedfetcher.prototype.displayoptions=function(a){this.showoptions=a};gfeedfetcher.prototype.setentrycontainer=function(a){this.itemcontainer=&quot;&amp;lt;&quot;+a.toLowerCase()+&quot;&amp;gt;&quot;};gfeedfetcher.prototype.init=function(){this.feedsfetched=0;this.feeds=[];this.feedcontainer.innerHTML=&#39;&amp;lt;img
 src=&quot;&#39;+gfeedfetcher_loading_image+&#39;&quot; /&amp;gt; Loading news...&#39;;var 
a=this;for(var b=0;b&amp;lt;this.feedurls.length;b++){var c=new 
google.feeds.Feed(this.feedurls[b]);var 
d=(this.feedlimit&amp;lt;=this.feedurls.length)?1:Math.floor(this.feedlimit/this.feedurls.length);if(this.feedlimit%this.feedurls.length&amp;gt;0&amp;amp;&amp;amp;this.feedlimit&amp;gt;this.feedurls.length&amp;amp;&amp;amp;b==this.feedurls.length-1){d+=(this.feedlimit%this.feedurls.length)}c.setNumEntries(d);c.load(function(e){return
 
function(f){a._fetch_data_as_array(f,e)}}(this.feedlabels[b]))}};gfeedfetcher._formatdate=function(a,c){var
 d=new Date(a);var 
b=(c.indexOf(&quot;datetime&quot;)!=-1)?d.toLocaleString():(c.indexOf(&quot;date&quot;)!=-1)?d.toLocaleDateString():(c.indexOf(&quot;time&quot;)!=-1)?d.toLocaleTimeString():&quot;&quot;;return&quot;&amp;lt;span
 
class=&#39;datefield&#39;&amp;gt;&quot;+b+&quot;&amp;lt;/span&amp;gt;&quot;};gfeedfetcher._sortarray=function(a,b){var
 
b=(b==&quot;label&quot;)?&quot;ddlabel&quot;:b;if(b==&quot;title&quot;||b==&quot;ddlabel&quot;){a.sort(function(e,d){var
 g=e[b].toLowerCase();var 
f=d[b].toLowerCase();return(g&amp;lt;f)?-1:(g&amp;gt;f)?1:0})}else{try{a.sort(function(e,d){return
 new Date(d.publishedDate)-new 
Date(e.publishedDate)})}catch(c){}}};gfeedfetcher.prototype._fetch_data_as_array=function(b,a){var
 d=(!b.error)?b.feed.entries:&quot;&quot;;if(d==&quot;&quot;){alert(&quot;Google Feed API Error: 
&quot;+b.error.message)}for(var 
c=0;c&amp;lt;d.length;c++){b.feed.entries[c].ddlabel=a}this.feeds=this.feeds.concat(d);this._signaldownloadcomplete()};gfeedfetcher.prototype._signaldownloadcomplete=function(){this.feedsfetched+=1;if(this.feedsfetched==this.feedurls.length){this._displayresult(this.feeds)}};gfeedfetcher.prototype._displayresult=function(a){var
 
e=(this.itemcontainer==&quot;&amp;lt;li&amp;gt;&quot;)?&quot;&amp;lt;ul&amp;gt;\n&quot;:&quot;&quot;;gfeedfetcher._sortarray(a,this.sortstring);for(var
 c=0;c&amp;lt;a.length;c++){var d=&#39;&amp;lt;a href=&quot;&#39;+a[c].link+&#39;&quot; 
target=&quot;&#39;+this.linktarget+&#39;&quot; 
class=&quot;titlefield&quot;&amp;gt;&#39;+a[c].title+&quot;&amp;lt;/a&amp;gt;&quot;;var 
b=/label/i.test(this.showoptions)?&#39;&amp;lt;span 
class=&quot;labelfield&quot;&amp;gt;[&#39;+this.feeds[c].ddlabel+&quot;]&amp;lt;/span&amp;gt;&quot;:&quot; &quot;;var 
g=gfeedfetcher._formatdate(a[c].publishedDate,this.showoptions);var 
f=/description/i.test(this.showoptions)?&quot;&amp;lt;br 
/&amp;gt;&quot;+a[c].content:/snippet/i.test(this.showoptions)?&quot;&amp;lt;br 
/&amp;gt;&quot;+a[c].contentSnippet:&quot;&quot;;e+=this.itemcontainer+d+&quot; &quot;+b+&quot; 
&quot;+g+&quot;\n&quot;+f+this.itemcontainer.replace(&quot;&amp;lt;&quot;,&quot;&amp;lt;/&quot;)+&quot;\n\n&quot;}e+=(this.itemcontainer==&quot;&amp;lt;li&amp;gt;&quot;)?&quot;&amp;lt;/ul&amp;gt;&quot;:&quot;&quot;;this.feedcontainer.innerHTML=e};&lt;br /&gt;
&lt;br /&gt;
var gfeedfetcher_loading_image=&quot;indicator.gif&quot;;function 
gfeedrssticker(d,b,a,c){this.tickerid=d;this.delay=parseInt(a);this.mouseoverBol=0;this.itemsperpage=1;this.messagepointer=0;gfeedfetcher.call(this,d,b,c);this.itemcontainer=&quot;&amp;lt;div&amp;gt;&quot;;this.tickerdiv=document.getElementById(d)}gfeedrssticker.prototype=new
 
gfeedfetcher;gfeedrssticker.prototype.constructor=gfeedrssticker;gfeedrssticker.prototype._displayresult=null;gfeedrssticker.prototype.entries_per_page=function(a){this.itemsperpage=a};gfeedrssticker.prototype._signaldownloadcomplete=function(){this.feedsfetched+=1;if(this.feedsfetched==this.feedurls.length){this._initscroller(this.feeds)}};gfeedrssticker.prototype._initscroller=function(a){var
 
c=this;gfeedfetcher._sortarray(a,this.sortstring);this.itemsperpage=(this.itemsperpage&amp;gt;=a.length)?1:this.itemsperpage;var
 
b=a.slice(this.messagepointer,this.itemsperpage);this.tickerdiv.innerHTML=formatrssmessage(b,this.showoptions,this.itemcontainer,this.linktarget);this.tickerdiv.onmouseover=function(){c.mouseoverBol=1};this.tickerdiv.onmouseout=function(){c.mouseoverBol=0};this.messagepointer=this.itemsperpage;if(window.attachEvent){window.attachEvent(&quot;onunload&quot;,function(){c.tickerdiv.onmouseover=c.tickerdiv.onmouseout=null})}setTimeout(function(){c._rotatemessage()},this.delay)};function
 formatrssmessage(d,b,f,g){var 
c=(f==&quot;&amp;lt;li&amp;gt;&quot;)?&quot;&amp;lt;ul&amp;gt;\n&quot;:&quot;&quot;;for(var e=0;e&amp;lt;d.length;e++){var
 h=&#39;&amp;lt;a href=&quot;&#39;+d[e].link+&#39;&quot; target=&quot;&#39;+g+&#39;&quot; 
class=&quot;titlefield&quot;&amp;gt;&#39;+d[e].title+&quot;&amp;lt;/a&amp;gt;&quot;;var 
j=/label/i.test(b)?&#39;&amp;lt;span 
class=&quot;labelfield&quot;&amp;gt;[&#39;+d[e].ddlabel+&quot;]&amp;lt;/span&amp;gt;&quot;:&quot; &quot;;var 
k=gfeedfetcher._formatdate(d[e].publishedDate,b);var 
a=/description/i.test(b)?&quot;&amp;lt;br 
/&amp;gt;&quot;+d[e].content:/snippet/i.test(b)?&quot;&amp;lt;br 
/&amp;gt;&quot;+d[e].contentSnippet:&quot;&quot;;c+=f+h+&quot; &quot;+j+&quot; 
&quot;+k+&quot;\n&quot;+a+f.replace(&quot;&amp;lt;&quot;,&quot;&amp;lt;/&quot;)+&quot;\n\n&quot;}c+=(f==&quot;&amp;lt;li&amp;gt;&quot;)?&quot;&amp;lt;/ul&amp;gt;\n&quot;:&quot;&quot;;return
 c}gfeedrssticker.prototype._rotatemessage=function(){var 
b=this;if(this.mouseoverBol==1){setTimeout(function(){b._rotatemessage()},100)}else{var
 
a=this.feeds.slice(this.messagepointer,this.messagepointer+this.itemsperpage);this.tickerdiv.innerHTML=formatrssmessage(a,this.showoptions,this.itemcontainer,this.linktarget);this.messagepointer=(this.messagepointer+this.itemsperpage&amp;gt;this.feeds.length-1)?0:this.messagepointer+this.itemsperpage;setTimeout(function(){b._rotatemessage()},this.delay)}};&lt;br /&gt;
//]]&amp;gt;&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;style type=&#39;text/css&#39;&amp;gt;&lt;br /&gt;
.titlefield{ /*CSS for RSS title link in general*/&lt;br /&gt;
text-decoration: none;}&lt;br /&gt;
.labelfield{ /*CSS for label field in general*/&lt;br /&gt;
color:#aaa;font-size: 100%;}&lt;br /&gt;
.datefield{ /*CSS for date field in general*/&lt;br /&gt;
color:#aaa;font:normal 14px Arial;text-transform:none;}&lt;br /&gt;
#example1{ /*Demo 1 main container*/&lt;br /&gt;
width: 780px;&lt;br /&gt;
height: 14px;&lt;br /&gt;
border: 0px solid #aaa;&lt;br /&gt;
padding: 0px;&lt;br /&gt;
font:bold 16px Arial;&lt;br /&gt;
text-transform:none;&lt;br /&gt;
text-align:left;&lt;br /&gt;
background-color:transparent;}&lt;br /&gt;
code{ /*CSS for insructions*/&lt;br /&gt;
color: #fff;}&lt;br /&gt;
#example1 a:link, #example1 a:visited {color:#f2f2f2;text-decoration:none;}&lt;br /&gt;
#example1 a:hover {color:#C8D3F2;text-decoration:none;}&lt;br /&gt;
&amp;lt;/style&amp;gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Kemudian cari kode&amp;nbsp;dibawah ini, atau kode yang biasa dipakai untuk meletakkan navigasi menu &lt;br /&gt;
&lt;pre class=&quot;code&quot;&gt;&amp;lt;div class=&#39;menu horizontal&#39;&amp;gt;
...........................................
...........................................
&amp;lt;/div&amp;gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Jika sudah ketemu letakkan kode berikut tepat dibawah kode &lt;b style=&quot;color: #cc0000;&quot;&gt;&amp;lt;/div&amp;gt;&lt;/b&gt; yang dipakai untuk menutup kode navigasi menu pada template Anda&lt;br /&gt;
&lt;div style=&quot;background-color: #c2c2c2; height: 350px; overflow: scroll; width: 100%;&quot;&gt;
&lt;br /&gt;
&amp;lt;div class=&#39;newspic&#39;&amp;gt;&lt;br /&gt;
&amp;lt;div style=&#39;float:left;width:780px;padding:6px 0 6px 180px; position:relative; overflow:hidden;&#39;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&#39;text/javascript&#39;&amp;gt;&lt;br /&gt;
var cssfeed=new gfeedrssticker(&amp;amp;quot;example1&amp;amp;quot;, &amp;amp;quot;example1class&amp;amp;quot;, 4000, &amp;amp;quot;_new&amp;amp;quot;)&lt;br /&gt;
cssfeed.addFeed(&amp;amp;quot;Creating Website&amp;amp;quot;, &amp;amp;quot;&lt;span style=&quot;color: red;&quot;&gt;http://armoe.blogspot.com&lt;/span&gt;/feeds/posts/default&amp;amp;quot;) //Specify &amp;amp;quot;label&amp;amp;quot; plus URL to RSS feed&lt;br /&gt;
cssfeed.displayoptions(&amp;amp;quot;date&amp;amp;quot;) //show the specified additional fields&lt;br /&gt;
cssfeed.setentrycontainer(&amp;amp;quot;div&amp;amp;quot;) //Wrap each entry with a DIV tag&lt;br /&gt;
cssfeed.filterfeed(10, &amp;amp;quot;date&amp;amp;quot;) //Show 10 entries, sort by date&lt;br /&gt;
cssfeed.entries_per_page(1)&lt;br /&gt;
cssfeed.init()&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&#39;clear:both;&#39;/&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Ganti URL yang saya beri warna &lt;span style=&quot;color: red;&quot;&gt;merah&lt;/span&gt; 
dengan URL blog anda dan jika blog anda masih baru newsticker ini 
biasanya tidak mau jalan karena google belum mengenal feed di blog Anda.
 Solusinya gampang Anda mesti buat API key sendiri di googlecode, atau 
langsung saja &lt;a href=&quot;http://code.google.com/apis/loader/signup.html&quot; target=&quot;_blank&quot;&gt;disin&lt;/a&gt;i.
 Masukkan URL blog anda, kemudian ganti kode javascript paling atas pada
 langkah nomer 5 dengan kode yang barusan dapet dari googlecode (bener 
nggak sih ngomongku...... &lt;/li&gt;
&lt;li&gt;&amp;nbsp;Langkah terakhir &lt;b&gt;save/simpan&lt;/b&gt;, lihat dibawah navigasi menu anda, kalau cara memasangnya sudah benar pasti akan muncul breaking news itu.&lt;/li&gt;
&lt;/ol&gt;
</content><link rel='replies' type='application/atom+xml' href='http://armoe.blogspot.com/feeds/7180417968398014836/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='http://armoe.blogspot.com/2014/02/membuat-widget-berita-berjalan-di-blog.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/7180417968398014836'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/7180417968398014836'/><link rel='alternate' type='text/html' href='http://armoe.blogspot.com/2014/02/membuat-widget-berita-berjalan-di-blog.html' title='Membuat Widget Berita Berjalan di Blog'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02277756216508959449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-zronFFOUYdKKbTMbtOp_Ida5G0APkGeqq1t4zfWkg5ONZaNTV8AZSOKLiggqYwUmRMClY8zI7TWC6ZA8f5KGf3OjqEZCOAsccjj7WEauZQP8y4BeRRfXQvcMg963HdRkWruw9BlgPkQS/s72-c/News+feed.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2065822655831694480.post-8119319221551264779</id><published>2014-02-02T20:19:00.000-08:00</published><updated>2016-06-17T15:23:56.575-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Sharp"/><category scheme="http://www.blogger.com/atom/ns#" term="Tutorial Bhs Indo"/><title type='text'>C# . Apa itu...?</title><content type='html'>&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://armoe.blogspot.com/&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7FPHS8ZFJ47CZdCCExMFnPf_dq15X7gnRUOweD5LGJqZDa5bCg-_hjjM0YScNCJ0ryJ3j0ggKCm6k2QWAhf7s4tlDwJ-qnNY1E7FmbHupft82W9KcwF_z_e7hI7bRIwvP0NsKVpigx0zH/s1600/c%23.png&quot; width=&quot;227&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;arial&amp;quot; , &amp;quot;sans-serif&amp;quot;;&quot;&gt;Pengertian C# (dibaca
“See-Sharp”) adalah bahasa pemrograman baru yang diciptakan oleh Microsoft
(dikembangkan dibawah kepemimpinan Anders Hejlsberg yang notabene juga telah
menciptakan berbagai macam bahasa pemrograman termasuk Borland Turbo C++ dan
Borland Delphi). Bahasa C# juga telah di standarisasi secara internasional oleh
ECMA. &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;arial&amp;quot; , &amp;quot;sans-serif&amp;quot;;&quot;&gt;Seperti halnya bahasa
pemrograman yang lain, C# bisa digunakan untuk membangun berbagai macam jenis
aplikasi, seperti aplikasi berbasis windows (desktop) dan aplikasi berbasis web
serta aplikasi berbasis web services. &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 3.0pt; margin-left: 18.0pt; margin-right: 0cm; margin-top: 12.0pt; mso-layout-grid-align: none; text-autospace: none; text-indent: -18.0pt;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;microsoft sans serif&amp;quot; , &amp;quot;sans-serif&amp;quot;; font-size: 14.0pt;&quot;&gt;Mengapa C# ? &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;arial&amp;quot; , &amp;quot;sans-serif&amp;quot;;&quot;&gt;Pertanyaan di atas mungkin
muncul di benak kita semua pada saat pertama kali mendengar tentang C#. Hal
tersebut sangat beralasan, dengan melihat kenyataan bahwa sebelum C# muncul,
telah banyak bahasa pemrograman yang ada, seperti C, C++, Java, Perl dan
lain-lain. &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;arial&amp;quot; , &amp;quot;sans-serif&amp;quot;;&quot;&gt;Ada beberapa alasan kenapa
memilih C#, yaitu : &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;arial&amp;quot; , &amp;quot;sans-serif&amp;quot;;&quot;&gt;Sederhana (simple) &lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;arial&amp;quot; , &amp;quot;sans-serif&amp;quot;;&quot;&gt;C# menghilangkan beberapa
hal yang bersifat kompleks yang terdapat dalam beberapa macam bahasa
pemrograman seperti Java dan C++, termasuk diantaranya mengilangkan &lt;i&gt;macro&lt;/i&gt;,
&lt;i&gt;templates&lt;/i&gt;, &lt;i&gt;multiple inheritance &lt;/i&gt;dan &lt;i&gt;virtual base classes&lt;/i&gt;.
Hal-hal tersebut yang dapat menyebabkan kebingunan pada saat menggunakannya,
dan juga berpotensial dapat menjadi masalah bagi para programmer C++. Jika anda
pertama kali belajar bahasa C# sebagai bahasa pemrograman, maka hal-hal
tersebut di atas tidak akan membuat waktu anda terbuang terlalu banyak untuk
mempelajarinya. &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;arial&amp;quot; , &amp;quot;sans-serif&amp;quot;;&quot;&gt;C# bersifat sederhana,
karena bahasa ini didasarkan kepada bahasa C dan C++. Jika anda familiar dengan
C dan C++ atau bahkan Java, anda akan menemukan aspek-aspek yang begitu
familiar, seperti &lt;i&gt;statements&lt;/i&gt;, &lt;i&gt;expression&lt;/i&gt;, &lt;i&gt;operators&lt;/i&gt;, dan
beberapa fungsi yang diadopsi langsung dari C dan C++, tetapi dengan berbagai
perbaikan yang membuat bahasanya menjadi lebih sederhana. &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;arial&amp;quot; , &amp;quot;sans-serif&amp;quot;;&quot;&gt;Modern &lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;arial&amp;quot; , &amp;quot;sans-serif&amp;quot;;&quot;&gt;Apa yang membuat C#
menjadi suatu bahasa pemrograman yang modern? Jawabannya adalah adanya beberapa
fitur seperti &lt;i&gt;exception handling&lt;/i&gt;, &lt;i&gt;garbage collection&lt;/i&gt;, &lt;i&gt;extensible
data types&lt;/i&gt;, dan &lt;i&gt;code security &lt;/i&gt;(keamanan kode/bahasa pemrograman).
Dengan adanya fitur-fitur tersebut, menjadikan bahasa C# sebagai bahasa
pemrograman yang modern. &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; page-break-before: always; text-align: justify; text-autospace: none;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;sans-serif&amp;quot;;&quot;&gt;Object-Oriented
Language &lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;sans-serif&amp;quot;;&quot;&gt;Kunci dari bahasa pemrograman yang
bersifat &lt;i&gt;Object Oriented &lt;/i&gt;adalah &lt;i&gt;encapsulation&lt;/i&gt;, &lt;i&gt;inheritance&lt;/i&gt;,
dan &lt;i&gt;polymorphism&lt;/i&gt;. Secara sederhana, istilah-istilah tersebut bisa
didefinisikan sebagai berikut (definisi dan penjelasan lebih lanjut akan di
uraikan pada bab-bab selanjutnya). &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;i&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;sans-serif&amp;quot;;&quot;&gt;encapsulation&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;sans-serif&amp;quot;;&quot;&gt;, dimana semua fungsi ditempatkan
dalam satu paket (&lt;i&gt;single package&lt;/i&gt;). &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;i&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;sans-serif&amp;quot;;&quot;&gt;inheritance, &lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;sans-serif&amp;quot;;&quot;&gt;adalah suatu cara yang terstruktur
dari suatu kode-kode pemrograman dan fungsi untuk menjadi sebuat program baru
dan berbentuk suatu paket. &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;i&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;sans-serif&amp;quot;;&quot;&gt;polymorphism, &lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;sans-serif&amp;quot;;&quot;&gt;adalah kemampuan untuk mengadaptasi
apa yang diperlukan untuk dikerjakan. &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;sans-serif&amp;quot;;&quot;&gt;Sifat-sifat tersebut di atas, telah di
miliki oleh C# sehingga bahasa C# merupakan bahasa yang bersifat &lt;i&gt;Object
Oriented&lt;/i&gt;. &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;sans-serif&amp;quot;;&quot;&gt;Powerfull dan fleksibel &lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;sans-serif&amp;quot;;&quot;&gt;C# bisa digunakan untuk membuat
berbagai macam aplikasi, seperti aplikasi pengolah kata, grapik, spreadsheets,
atau bahkan membuat kompiler untuk sebuah bahasa permrograman. &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;sans-serif&amp;quot;;&quot;&gt;Efisien &lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;sans-serif&amp;quot;;&quot;&gt;C# adalah bahasa pemrograman yang
menggunakan jumlah kata-kata yang tidak terlalu banyak. C# hanya berisi kata-kata
yang biasa disebut dengan &lt;i&gt;keywords&lt;/i&gt;. &lt;i&gt;Keywords &lt;/i&gt;ini digunakan untuk
menjelaskan berbagai macam informasi. Jika anda berpikiran bahwa bahasa
pemrograman yang menggunakan sangat banyak kata-kata (&lt;i&gt;keywords&lt;/i&gt;) akan
lebih powerfull, maka jawabannya adalah “pemikiran itu tidak selalu benar”,
karena hal itu justru bisa menambah kerumitan para developer pada saat membuat
suatu aplikasi. Berikut daftar &lt;i&gt;keywords &lt;/i&gt;yang ada dalam bahasa C#: &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 0cm; margin-top: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;lucida console&amp;quot;; font-size: 10.0pt;&quot;&gt;Abstract&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;as&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;base&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;bool&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;break &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 0cm; margin-top: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;lucida console&amp;quot;; font-size: 10.0pt;&quot;&gt;byte &lt;span style=&quot;mso-tab-count: 2;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;case &lt;span style=&quot;mso-tab-count: 1;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;catch &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;char
&lt;span style=&quot;mso-tab-count: 2;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;checked &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 0cm; margin-top: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;lucida console&amp;quot;; font-size: 10.0pt;&quot;&gt;class &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;const &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;continue
&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;decimal &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;default &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 0cm; margin-top: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;lucida console&amp;quot;; font-size: 10.0pt;&quot;&gt;delegate &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;do &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;double &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;else
&lt;span style=&quot;mso-tab-count: 2;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;enum &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 0cm; margin-top: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;lucida console&amp;quot;; font-size: 10.0pt;&quot;&gt;event &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;explicit &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;extern
&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;false &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;finally &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 0cm; margin-top: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;lucida console&amp;quot;; font-size: 10.0pt;&quot;&gt;fixed &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;float &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;for
&lt;span style=&quot;mso-tab-count: 2;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;foreach &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 0cm; margin-top: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;lucida console&amp;quot;; font-size: 10.0pt;&quot;&gt;goto &lt;span style=&quot;mso-tab-count: 2;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if &lt;span style=&quot;mso-tab-count: 2;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;implicit
&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;in &lt;span style=&quot;mso-tab-count: 2;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;int
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 0cm; margin-top: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;lucida console&amp;quot;; font-size: 10.0pt;&quot;&gt;interface &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp; &lt;/span&gt;internal &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;is
&lt;span style=&quot;mso-tab-count: 2;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;lock l&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;ong &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 0cm; margin-top: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;lucida console&amp;quot;; font-size: 10.0pt;&quot;&gt;namespace &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp; &lt;/span&gt;new &lt;span style=&quot;mso-tab-count: 2;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;null
&lt;span style=&quot;mso-tab-count: 2;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;object &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;operator &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 0cm; margin-top: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;lucida console&amp;quot;; font-size: 10.0pt;&quot;&gt;out &lt;span style=&quot;mso-tab-count: 2;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;override &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;params &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;private &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;protected &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 0cm; margin-top: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;lucida console&amp;quot;; font-size: 10.0pt;&quot;&gt;public &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;readonly &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;ref
&lt;span style=&quot;mso-tab-count: 2;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;return &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;sbyte &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 0cm; margin-top: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;lucida console&amp;quot;; font-size: 10.0pt;&quot;&gt;sealed &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;short &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;sizeof
&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;stackalloc &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 0cm; margin-top: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;lucida console&amp;quot;; font-size: 10.0pt;&quot;&gt;static &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;string &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;struct
&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;switch &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;this &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 0cm; margin-top: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;lucida console&amp;quot;; font-size: 10.0pt;&quot;&gt;throw &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;true &lt;span style=&quot;mso-tab-count: 2;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;try
&lt;span style=&quot;mso-tab-count: 2;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;typeof &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;uint &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 0cm; margin-top: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;lucida console&amp;quot;; font-size: 10.0pt;&quot;&gt;ulong &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;unchecked &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp; &lt;/span&gt;unsafe
&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;ushort &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;using &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 0cm; margin-top: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;lucida console&amp;quot;; font-size: 10.0pt;&quot;&gt;virtual &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;void &lt;span style=&quot;mso-tab-count: 2;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;while
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 0cm; margin-top: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-align: center; text-autospace: none;&quot;&gt;
&lt;i&gt;&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , &amp;quot;serif&amp;quot;;&quot;&gt;Daftar keywords
pada bahasa C# &lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; page-break-before: always; text-align: justify; text-autospace: none;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;sans-serif&amp;quot;;&quot;&gt;Modular &lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;sans-serif&amp;quot;;&quot;&gt;Kode C# ditulis dengan pembagian
masing Class-Class (&lt;i&gt;classes&lt;/i&gt;) yang terdiri dari beberapa &lt;i&gt;routines &lt;/i&gt;yang
disebut sebagai &lt;i&gt;member methods&lt;/i&gt;. Class-Class dan metode-metode ini dapat
digunakan kembali oleh program atau aplikasi lain. Hanya dengan memberikan
informasi yang dibutuhkan oleh Class dan metode yang dimaksud, maka kita akan
dapat membuat suata kode yang dapat digunakan oleh satu atau beberapa aplikasi
dan program (&lt;i&gt;reusable code&lt;/i&gt;)&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-align: justify; text-autospace: none;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;sans-serif&amp;quot;;&quot;&gt;C# akan menjadi populer &lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;sans-serif&amp;quot;;&quot;&gt;Dengan dukungan
penuh dari Microsoft yang akan mengeluarkan produk-produk utamanya dengan
dukungan Framework .NET, maka masa depan bahasa C# sebagai salah satu bahasa
pemrograman yang ada di dalam lingkungan Framework .NET akan lebih baik.&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://armoe.blogspot.com/feeds/8119319221551264779/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='http://armoe.blogspot.com/2014/02/c-sharp-apa-itu.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/8119319221551264779'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/8119319221551264779'/><link rel='alternate' type='text/html' href='http://armoe.blogspot.com/2014/02/c-sharp-apa-itu.html' title='C# . Apa itu...?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02277756216508959449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7FPHS8ZFJ47CZdCCExMFnPf_dq15X7gnRUOweD5LGJqZDa5bCg-_hjjM0YScNCJ0ryJ3j0ggKCm6k2QWAhf7s4tlDwJ-qnNY1E7FmbHupft82W9KcwF_z_e7hI7bRIwvP0NsKVpigx0zH/s72-c/c%23.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2065822655831694480.post-2492162027491230553</id><published>2014-02-02T19:03:00.002-08:00</published><updated>2016-06-17T15:23:56.569-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Tutorial Bhs Indo"/><category scheme="http://www.blogger.com/atom/ns#" term="Tutorial Blog"/><title type='text'>Membuat Multi Tab di Blogspot Tanpa Edit HTML</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1Y6GqaGFtmwYSy0YCcktT_M8wUiti24xMto5b1rRqKTV8fxUeaJHk1v2bbtfnqxFwOT0oTFb1DlqWjUXtiMNZiFE1fWLsr_M9W1J6YFKa82f3ztbe3gPsoB-mlSaMskFchrT1tkXGMBWj/s1600/tab.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1Y6GqaGFtmwYSy0YCcktT_M8wUiti24xMto5b1rRqKTV8fxUeaJHk1v2bbtfnqxFwOT0oTFb1DlqWjUXtiMNZiFE1fWLsr_M9W1J6YFKa82f3ztbe3gPsoB-mlSaMskFchrT1tkXGMBWj/s1600/tab.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Tab Multi Widget 
adalah penggabungan beberapa Widget pada satu kolom dengan Tab. Tab 
Multi widget ini sangat berguna jika Blog sobat mempunyai terlalu banyak
 widget. Sobat bisa menggabungkan widget-widget tersebut pada satu kolom
 dengan Tab diatasnya. Jadi sobat tidak&lt;br /&gt;
&lt;a href=&quot;https://www.blogger.com/null&quot; name=&quot;more&quot;&gt;&lt;/a&gt; perlu menyediakan area yang luas untuk widget yang banyak.&lt;br /&gt;
Oke langsung saja ke langkah-langkah pembuatanya. &lt;br /&gt;
&lt;br /&gt;
1. Login ke kaun Blogger sobat.&lt;br /&gt;
2. Masuk pada bagian Template.&lt;br /&gt;
3. Pilih Edit HTML.&lt;br /&gt;
4. Cari kode &lt;b&gt;&amp;lt;/head&amp;gt;&lt;/b&gt;, agar lebih mudah gunakan tombol ctrl+F.&lt;br /&gt;
5. Masukan kode &lt;b&gt;&lt;a href=&quot;http://armoe.blogspot.com/&quot;&gt;&amp;lt;script src=&#39;http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js&#39; type=&#39;text/javascript&#39;/&amp;gt;&lt;/a&gt; &lt;/b&gt;, di atas kode &lt;b&gt;&amp;lt;/head&amp;gt;&lt;/b&gt;.&lt;br /&gt;
6. Klik simpan Template.&lt;br /&gt;
7. Selanjutnya masuk ke bagian Tata Letak.&lt;br /&gt;
8. Klik Tambah Gacget di posisi yang sobat inginkan.&lt;br /&gt;
9. Pilih HTML/Javascript.&lt;br /&gt;
10. Masukan kode berikut.
&lt;br /&gt;
&lt;div style=&quot;background-color: #c2c2c2; height: 350px; overflow: scroll; width: 100%;&quot;&gt;
&amp;lt;style type=&quot;text/css&quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .blogtabs {padding:&lt;span style=&quot;background-color: white;&quot;&gt; &lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: lime;&quot;&gt;0px&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; !important;border: &lt;span style=&quot;color: lime;&quot;&gt;0&lt;/span&gt; solid &lt;span style=&quot;color: blue;&quot;&gt;#bbb&lt;/span&gt;;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .blogtabs h2 {float: left;margin: &lt;span style=&quot;color: lime;&quot;&gt;0 2px&lt;/span&gt; &lt;span style=&quot;color: lime;&quot;&gt;4px 0&lt;/span&gt;;font-size: &lt;span style=&quot;color: lime;&quot;&gt;12px&lt;/span&gt;;padding: &lt;span style=&quot;color: lime;&quot;&gt;3px&lt;/span&gt; &lt;span style=&quot;color: lime;&quot;&gt;5px&lt;/span&gt;;border: &lt;span style=&quot;color: lime;&quot;&gt;1px&lt;/span&gt; solid &lt;span style=&quot;color: blue;&quot;&gt;#bbb&lt;/span&gt;;overflow: hidden;position: relative;background:&lt;span style=&quot;color: blue;&quot;&gt; #e0e0e0&lt;/span&gt;;cursor:pointer;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; html .blogtabs h2.active {background: &lt;span style=&quot;color: blue;&quot;&gt;#fff&lt;/span&gt;;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .blogtabs .widget-content {border: 1px solid &lt;span style=&quot;color: blue;&quot;&gt;#bbb&lt;/span&gt;;padding: &lt;span style=&quot;color: lime;&quot;&gt;10px&lt;/span&gt;;background: &lt;span style=&quot;color: blue;&quot;&gt;#fff&lt;/span&gt;;clear:both;margin:0;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .btab, #showtabs {display:none;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/style&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
 &amp;lt;script type=&quot;text/javascript&quot; 
src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://ayriyzone.googlecode.com/files/SimpleTabViewJQuery.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;script type=&quot;text/javascript&quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(&#39;#showtabs&#39;).simpleBlogTab ({&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;organictabs: 3&lt;/span&gt;&lt;/b&gt;});&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div id=&quot;showtabs&quot;&amp;gt;&amp;lt;/div&amp;gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Keterangan&lt;/b&gt;, &lt;span style=&quot;color: blue;&quot;&gt;kode berwarna biru&lt;/span&gt; adalah kode-kode warna, &lt;span style=&quot;color: lime;&quot;&gt;kode berwarna hijau&lt;/span&gt; adalah kode-kode ukuran yang bisa sobat ubah. Sedangkan kode  ({&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;organictabs: &lt;u&gt;3&lt;/u&gt;&lt;/span&gt;&lt;/b&gt;}) adalah jumlah tab yang akan digabungkan dan sobat bisa sesuaikan.&lt;br /&gt;
&lt;br /&gt;
11. Klik Simpan.&lt;br /&gt;
12. Letakan widget-widget yang akan digabungkan tepat di bawah widget yang baru saja dibuat.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4WhGSpUu0j1KNTt-oA9UGqr067Uxa7WYwU4AVptHBoJu5yKDO15r7c1WO5LjzZHvSYyDgoxNQvoEJ6JDYy8tgNjZaMwWtaGgNvwBfjgAGTr5NhsoPPnqqWQ9QjdsYerOqtnY7AVIN8X4/s1600/Untitled3.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Cara Membuat Tab Multi Widget di Blog&quot; border=&quot;0&quot; height=&quot;287&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4WhGSpUu0j1KNTt-oA9UGqr067Uxa7WYwU4AVptHBoJu5yKDO15r7c1WO5LjzZHvSYyDgoxNQvoEJ6JDYy8tgNjZaMwWtaGgNvwBfjgAGTr5NhsoPPnqqWQ9QjdsYerOqtnY7AVIN8X4/s400/Untitled3.png&quot; title=&quot;Cara Membuat Tab Multi Widget di Blog&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Selesai, sobat dapat lihat hasilnya.</content><link rel='replies' type='application/atom+xml' href='http://armoe.blogspot.com/feeds/2492162027491230553/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='http://armoe.blogspot.com/2014/02/membuat-multi-tab-di-blogspot-tanpa.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/2492162027491230553'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2065822655831694480/posts/default/2492162027491230553'/><link rel='alternate' type='text/html' href='http://armoe.blogspot.com/2014/02/membuat-multi-tab-di-blogspot-tanpa.html' title='Membuat Multi Tab di Blogspot Tanpa Edit HTML'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02277756216508959449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1Y6GqaGFtmwYSy0YCcktT_M8wUiti24xMto5b1rRqKTV8fxUeaJHk1v2bbtfnqxFwOT0oTFb1DlqWjUXtiMNZiFE1fWLsr_M9W1J6YFKa82f3ztbe3gPsoB-mlSaMskFchrT1tkXGMBWj/s72-c/tab.png" height="72" width="72"/><thr:total>0</thr:total></entry></feed>