<?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-9024993991083531887</id><updated>2026-04-18T13:28:59.510+07:00</updated><category term="JavaScript Dasar"/><category term="function &amp; scope"/><title type='text'>Blogcilik</title><subtitle type='html'>&quot;jika hidup tidak berjalan sesuai rencana, coba console.log() dulu.&quot; blog ngoding javascript</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://blog-cilik.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default'/><link rel='alternate' type='text/html' href='https://blog-cilik.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>blogcilik</name><uri>http://www.blogger.com/profile/15754422881593101752</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>24</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-9024993991083531887.post-8141678961015198833</id><published>2026-02-21T18:59:00.002+07:00</published><updated>2026-02-21T18:59:23.744+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="function &amp; scope"/><title type='text'>Function &amp; Scope dalam JavaScript: Fondasi Penting yang Wajib Dipahami</title><content type='html'>&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kalau kamu sedang belajar JavaScript—apalagi kalau ingin serius masuk ke dunia web development atau bahkan AI berbasis JavaScript—dua konsep yang wajib benar-benar dipahami adalah: function dan scope.&lt;br /&gt;Kenapa?&lt;br /&gt;Karena hampir semua logika program JavaScript berdiri di atas dua hal ini.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Apa Itu Function di JavaScript?&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Function adalah blok kode yang bisa dipanggil kembali untuk menjalankan tugas tertentu.&lt;br /&gt;Bayangkan function seperti “mesin kecil” yang bisa kamu gunakan berulang kali tanpa harus menulis ulang kodenya.&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;🔹&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh Dasar Function :&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;function sapa() {
  console.log(&quot;Halo dunia!&quot;);
}

sapa(); // Memanggil function&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;

Output:

&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;Halo dunia!&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;🔹&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Function dengan Parameter&lt;/span&gt;&lt;/h3&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Parameter membuat function jadi fleksibel.&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;function sapa(nama) {
  console.log(&quot;Halo &quot; + nama);
}

sapa(&quot;Budi&quot;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;

Output:

&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;Halo Budi&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;🔹&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Function dengan Return Value&lt;/span&gt;&lt;/h3&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Function juga bisa mengembalikan nilai.&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;function tambah(a, b) {
  return a + b;
}

let hasil = tambah(5, 3);
console.log(hasil);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;

Output:

&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;8&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt; itu penting. Tanpa return, function hanya menjalankan kode tapi tidak mengembalikan hasil.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Jen&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;is-Jenis Function di JavaScript&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;🔹&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Function Declaration&lt;/span&gt;&lt;/h3&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;function kali(a, b) {
  return a * b;
}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Bisa dipanggil sebelum didefinisikan (karena hoisting).&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;🔹&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Function Expression&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;const bagi = function(a, b) {
  return a / b;
};&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tidak bisa dipanggil sebelum didefinisikan.&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;🔹&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Arrow Function (Modern JavaScript)&lt;/span&gt;&lt;/h3&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;const kurang = (a, b) =&amp;gt; {
  return a - b;
};&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;

Versi singkatnya:

&lt;/span&gt;&lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;const kurang = (a, b) =&amp;gt; a - b;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Arrow function sering dipakai di React, Node.js, dan berbagai framework modern.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Apa Itu Scope?&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Scope adalah ruang lingkup di mana sebuah variabel bisa diakses.&lt;br /&gt;Banyak bug di JavaScript terjadi karena orang belum paham scope.&lt;br /&gt;&lt;/span&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;🔹 Global Scope&lt;/span&gt;&lt;/h3&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Variabel yang dideklarasikan di luar function bisa diakses di mana saja.&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;let nama = &quot;Andi&quot;;

function cetak() {
  console.log(nama);
}

cetak();  &lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;🔹 Function Scope&lt;/span&gt;&lt;/h3&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Variabel yang dibuat di dalam function hanya bisa diakses di dalam function itu saja.&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;function contoh() {
  let umur = 25;
  console.log(umur);
}

contoh();
console.log(umur); // Error!  &lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kenapa error?&lt;br /&gt;Karena umur hanya hidup di dalam function.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;🔹 Block Scope (let &amp;amp; const)&lt;/span&gt;&lt;/h3&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Sejak ES6, let dan const punya block scope.&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;if (true) {
  let angka = 10;
  console.log(angka);
}

console.log(angka); // Error&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Berbeda dengan var yang tidak punya block scope.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Scope Chain (Konsep Penting!)&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript mencari variabel dari dalam ke luar.&lt;br /&gt;Contoh:&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let globalVar = &quot;Saya global&quot;;

function luar() {
  let luarVar = &quot;Saya di luar&quot;;

  function dalam() {
    console.log(globalVar);
    console.log(luarVar);
  }

  dalam();
}

luar();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Urutan pencarian:&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Cek di dalam function sekarang&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Jika tidak ada, naik ke atas&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Terus naik sampai global&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Jika tidak ketemu → error&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Inilah yang disebut scope chain.&lt;br /&gt;&lt;/span&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kenapa Ini Penting?&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kalau kamu:&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mau jadi web developer&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mau masuk ke backend Node.js&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mau belajar React&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mau bikin logic trading bot&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mau bikin AI berbasis JavaScript&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;Maka memahami function &amp;amp; scope itu bukan pilihan — itu wajib.&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;Karena:&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;80% bug pemula berasal dari scope&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Closure (konsep lanjutan) bergantung pada scope&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Async programming juga sangat berkaitan dengan function&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kesalahan Umum Pemula&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;❌ Lupa pakai let / const&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;❌ Salah paham hoisting&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;❌ Mengira variabel di dalam function bisa diakses di luar&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;❌ Terlalu banyak global variable&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kesimpulan&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Function = Mesin logika&lt;br /&gt;Scope = Batas wilayah variabel&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;Kalau kamu kuasai dua ini, kamu sudah naik level dari pemula ke menengah.&lt;/span&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='https://blog-cilik.blogspot.com/feeds/8141678961015198833/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='https://blog-cilik.blogspot.com/2026/02/function-scope-dalam-javascript-fondasi.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/8141678961015198833'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/8141678961015198833'/><link rel='alternate' type='text/html' href='https://blog-cilik.blogspot.com/2026/02/function-scope-dalam-javascript-fondasi.html' title='Function &amp; Scope dalam JavaScript: Fondasi Penting yang Wajib Dipahami'/><author><name>blogcilik</name><uri>http://www.blogger.com/profile/15754422881593101752</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-9024993991083531887.post-4593905022322931062</id><published>2026-02-11T12:12:00.003+07:00</published><updated>2026-02-11T12:12:42.036+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="function &amp; scope"/><title type='text'>Apa Itu Function dalam Javascript Pengertian dan Konsep Dasar</title><content type='html'>&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Waktu pertama kali belajar JavaScript, saya pikir function itu cuma “cara bikin kode lebih rapi”.&lt;br /&gt;Ternyata saya salah besar.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;Saya baru sadar pentingnya function ketika kode saya mulai berantakan. Setiap mau menampilkan teks, menghitung angka, atau melakukan proses kecil, saya copy–paste kode yang sama berkali-kali. Awalnya terasa cepat… tapi lama-lama malah bikin pusing sendiri.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;Di situlah saya mulai benar-benar memahami apa itu function.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Saat Kode Mulai Berantakan&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Bayangkan saya punya kode seperti ini:&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;console.log(&quot;Halo, selamat datang!&quot;);
console.log(&quot;Halo, selamat datang!&quot;);
console.log(&quot;Halo, selamat datang!&quot;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kelihatannya tidak masalah. Tapi bagaimana kalau teksnya harus diubah?&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;Saya harus ubah satu per satu.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;Di situ saya berpikir,&lt;br /&gt;“Kenapa tidak dibuat satu saja, lalu dipanggil berulang?”&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;Dan di situlah saya bertemu dengan function.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Apa Itu Function Sebenarnya?&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dari pengalaman saya, function itu seperti tombol otomatis.&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;Kita tulis sekali apa yang harus dilakukan.&lt;br /&gt;Lalu setiap kali butuh, kita tinggal tekan tombolnya.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;Secara sederhana:&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;font-size: xx-small;&quot;&gt;Function adalah blok kode yang bisa disimpan, lalu dijalankan kapan pun kita mau.&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh Function yang Pertama Kali Saya Buat&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Waktu itu saya coba menulis seperti ini:&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;function sapa() {
  console.log(&quot;Halo, selamat datang!&quot;);
}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Lalu saya jalankan:&lt;/span&gt;&lt;/p&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;sapa();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dan hasilnya:&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;Halo, selamat datang!&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Saat itu saya langsung merasa,&lt;br /&gt;&lt;b&gt;“Wah… ternyata semudah ini.”&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;Tidak perlu tulis ulang berkali-kali. Cukup panggil namanya saja.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kenapa Saya Akhirnya Sadar Function Itu Penting&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Setelah beberapa latihan kecil, saya mulai paham:&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tanpa function → kode cepat panjang&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tanpa function → sulit diperbaiki&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tanpa function → mudah salah&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;Tapi dengan function:&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;✔ Kode lebih pendek&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;✔ Lebih mudah dibaca&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;✔ Lebih terstruktur&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;✔ Bisa digunakan ulang&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;Semakin besar programnya, semakin terasa manfaatnya.&lt;br /&gt;&lt;/span&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Cara Saya Mengingat Konsep Function&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Saya biasanya mengibaratkan function seperti resep masakan.&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;Resep ditulis satu kali.&lt;br /&gt;Tapi bisa dipakai berkali-kali.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;Kalau ingin hasil berbeda?&lt;br /&gt;Tinggal ubah bahan (nanti kita belajar soal parameter).&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;Konsep ini yang akhirnya membuat saya lebih mudah memahami JavaScript tahap selanjutnya.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kesalahan yang Pernah Saya Lakukan&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Jujur saja, saya dulu sering lupa memanggil function.&lt;br /&gt;Saya sudah buat:&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;function sapa() {
  console.log(&quot;Halo!&quot;);
}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;

Tapi lupa menulis:

&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;sapa();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Akhirnya tidak muncul apa-apa, dan saya bingung sendiri.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;Dari situ saya belajar:&lt;br /&gt;Membuat function saja tidak cukup — kita harus memanggilnya.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kenapa Kamu Harus Paham Function Sejak Awal&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Berdasarkan pengalaman saya belajar JavaScript, hampir semua konsep lanjutan bergantung pada function:&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Scope&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Closure&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Callback&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Asynchronous programming&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;Kalau fondasi function belum kuat, materi lanjutan akan terasa membingungkan.&lt;br /&gt;Saya sendiri merasakannya.&lt;br /&gt;&lt;/span&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kesimpulan&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dulu saya menganggap function hanya fitur tambahan.&lt;br /&gt;Sekarang saya sadar, function adalah jantung dari JavaScript.&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;Belajar function bukan cuma soal sintaks, tapi soal cara berpikir:&lt;br /&gt;Bagaimana membuat kode lebih terstruktur dan bisa digunakan kembali.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;Kalau kamu sedang belajar JavaScript, percayalah — pahami function dulu dengan benar. Setelah itu, banyak hal akan terasa lebih masuk akal.&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://blog-cilik.blogspot.com/feeds/4593905022322931062/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='https://blog-cilik.blogspot.com/2026/02/apa-itu-function-dalam-javascript.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/4593905022322931062'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/4593905022322931062'/><link rel='alternate' type='text/html' href='https://blog-cilik.blogspot.com/2026/02/apa-itu-function-dalam-javascript.html' title='Apa Itu Function dalam Javascript Pengertian dan Konsep Dasar'/><author><name>blogcilik</name><uri>http://www.blogger.com/profile/15754422881593101752</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-9024993991083531887.post-8231005516375213156</id><published>2026-02-11T11:16:00.000+07:00</published><updated>2026-02-11T11:16:29.405+07:00</updated><title type='text'>Airdrop Crypto: Apa Itu, Cara Kerja, dan Peran JavaScript di Baliknya</title><content type='html'>&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dalam beberapa tahun terakhir, istilah &lt;i&gt;&lt;span style=&quot;color: #990000;&quot;&gt;airdrop crypto&lt;/span&gt;&lt;/i&gt; semakin sering dibicarakan. Banyak pengguna Web3 mendapatkan token gratis hanya dengan melakukan interaksi sederhana seperti swap, bridge, atau staking.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Namun, sebenarnya apa itu airdrop? Dan apa hubungannya dengan JavaScript?&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Artikel ini akan membahasnya dari sudut pandang teknis — khususnya untuk developer JavaScript.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Apa Itu Airdrop?&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Airdrop adalah distribusi token gratis dari sebuah proyek crypto kepada pengguna yang memenuhi syarat tertentu.&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Biasanya syaratnya seperti:&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menggunakan dApp mereka&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Melakukan transaksi tertentu&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menyediakan likuiditas&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mengikuti testnet&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tujuannya adalah:&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Meningkatkan awareness&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menghargai early adopter&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mendistribusikan token secara lebih merata&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Bagaimana Airdrop Ditentukan?&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Sebagian besar proyek menentukan penerima airdrop berdasarkan:&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Snapshot wallet address&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Jumlah transaksi&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Volume transaksi&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Interaksi dengan smart contract tertentu&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Semua data ini tersimpan di blockchain dan bisa diakses melalui RPC atau API.&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Di sinilah JavaScript berperan.&lt;br /&gt;&lt;/span&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Peran JavaScript dalam Ekosistem Airdrop&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Developer JavaScript bisa:&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;1️⃣ Mengecek Kelayakan Airdrop Menggunakan Web3.js atau Ethers.js&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh sederhana menggunakan ethers.js:&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;import { ethers } from &quot;ethers&quot;;

const provider = new ethers.JsonRpcProvider(&quot;https://rpc.ankr.com/eth&quot;);
const address = &quot;0xYourWalletAddress&quot;;

async function checkBalance() {
  const balance = await provider.getBalance(address);
  console.log(&quot;Balance:&quot;, ethers.formatEther(balance));
}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;checkBalance();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Script seperti ini bisa digunakan untuk:&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mengecek histori transaksi&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menghitung volume&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mengambil event smart contract&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;2️⃣ Membuat Script Monitoring Airdrop&lt;/span&gt;&lt;/h3&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Developer bisa membuat:&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Bot notifikasi airdrop&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Script pemantau snapshot&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dashboard tracking eligibility&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Biasanya menggunakan:&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Node.js&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Express&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Web3.js&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Ethers.js&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;The Graph API&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;3️⃣ Membuat Tools Eligibility Checker&lt;/span&gt;&lt;/h3&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Beberapa website airdrop checker dibuat menggunakan:&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;React (Frontend)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Node.js (Backend)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Web3 library&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;User cukup connect wallet → sistem membaca data on-chain → menentukan apakah eligible atau tidak.&lt;br /&gt;&lt;/span&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Apakah Aman Mengikuti Airdrop?&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Sebagai developer, penting memahami risiko:&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;⚠️ Banyak scam airdrop&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;⚠️ Website palsu yang meminta private key&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;⚠️ Smart contract berbahaya&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tips aman:&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Jangan pernah share private key&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Gunakan wallet khusus airdrop&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Cek kontrak di Etherscan&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Peluang untuk Developer JavaScript&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Jika kamu menguasai JavaScript, kamu bisa:&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Membuat dashboard analytics Web3&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Membuat bot monitoring airdrop&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Membuat tool auto-check eligibility&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Membangun dApp sendiri dengan sistem reward&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Airdrop bukan hanya soal “token gratis”, tapi juga peluang membangun produk di ekosistem Web3.&lt;br /&gt;&lt;/span&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kesimpulan&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Airdrop adalah bagian dari strategi distribusi token dalam dunia crypto. Di baliknya, terdapat data on-chain yang bisa diakses dan dianalisis menggunakan JavaScript.&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Bagi developer, ini bukan sekadar tren, tetapi peluang untuk:&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Belajar Web3&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Membangun tools&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Membuat produk berbasis blockchain&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Jika kamu ingin mendalami Web3 dengan JavaScript, memahami mekanisme airdrop adalah langkah awal yang bagus.&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://blog-cilik.blogspot.com/feeds/8231005516375213156/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='https://blog-cilik.blogspot.com/2026/02/airdrop-crypto-apa-itu-cara-kerja-dan.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/8231005516375213156'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/8231005516375213156'/><link rel='alternate' type='text/html' href='https://blog-cilik.blogspot.com/2026/02/airdrop-crypto-apa-itu-cara-kerja-dan.html' title='Airdrop Crypto: Apa Itu, Cara Kerja, dan Peran JavaScript di Baliknya'/><author><name>blogcilik</name><uri>http://www.blogger.com/profile/15754422881593101752</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-9024993991083531887.post-6846804872279492123</id><published>2026-01-20T20:49:00.003+07:00</published><updated>2026-01-20T20:49:57.307+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript Dasar"/><title type='text'>Struktur Dasar JavaScript: Kesalahan Umum yang Sering Terjadi pada Pemula</title><content type='html'>&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Belajar JavaScript sering terasa membingungkan di awal. Banyak pemula langsung mencoba menulis kode, tetapi hasilnya error, tidak jalan, atau malah tidak tahu salahnya di mana. Masalah utamanya &lt;b&gt;bukan JavaScript yang sulit&lt;/b&gt;, melainkan &lt;b&gt;belum paham struktur dasarnya&lt;/b&gt;.&lt;br /&gt;Artikel ini akan membahas struktur dasar JavaScript &lt;b&gt;berdasarkan kondisi nyata&lt;/b&gt; yang sering dialami pemula, lengkap dengan contoh kesalahan umum dan cara memperbaikinya.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;1. JavaScript Selalu Berjalan dari Atas ke Bawah&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Kesalahan yang sering terjadi&lt;/b&gt;&lt;br /&gt;Banyak pemula mengira JavaScript bisa membaca kode “acak” seperti manusia.&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;
    JavaScript
  &lt;/span&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;console.log(nama);
var nama = &quot;Andi&quot;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;

Hasil&lt;/b&gt;: undefined

&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Pemula sering bertanya:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;blockquote&gt;“Kenapa tidak error, tapi juga tidak keluar ‘Andi’?”&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Penjelasan realistis&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript membaca kode &lt;b&gt;dari atas ke bawah&lt;/b&gt;. Saat &lt;/span&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;console.log(nama) &lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;dijalankan, variabel &lt;/span&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;nama&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt; &lt;b&gt;belum berisi nilai.&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Cara yang benar&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;
    JavaScript
  &lt;/span&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;var nama = &quot;Andi&quot;;
console.log(nama);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;2. Setiap Perintah Biasanya Diakhiri Titik Koma &lt;/span&gt;&lt;span style=&quot;color: #666666; font-family: courier;&quot;&gt;(;)&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Kesalahan umum&lt;/b&gt;&lt;br /&gt;Pemula sering lupa titik koma atau menulis kode panjang tanpa struktur jelas.&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;
    JavaScript
  &lt;/span&gt;&lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;var umur = 20
var status = &quot;pelajar&quot;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript memang &lt;b&gt;kadang masih jalan,&lt;/b&gt; tapi ini sering memicu bug di kode besar.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;b&gt;Praktik yang disarankan&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;
    JavaScript
  &lt;/span&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;var umur = 20;
var status = &quot;pelajar&quot;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;💡 Biasakan pakai titik koma agar kode rapi dan aman.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;3. JavaScript Peka Terhadap Huruf Besar dan Kecil&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Kesalahan paling sering&lt;/b&gt;&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;
    JavaScript
  &lt;/span&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;var nama = &quot;Budi&quot;;
console.log(Nama);
Error: Nama is not defined&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Penjelasan&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;nama&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt; dan &lt;/span&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;Nama&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt; &lt;b&gt;dianggap dua variabel berbeda.&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Solusi&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Gunakan konsistensi:&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;
    JavaScript
  &lt;/span&gt;&lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;var nama = &quot;Budi&quot;;
console.log(nama);  &lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;4. Penulisan Kurung Kurawal &lt;/span&gt;&lt;span style=&quot;color: #666666; font-family: courier;&quot;&gt;{}&lt;/span&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt; yang Sering Terlewat&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Kesalahan nyata&lt;/b&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;
    JavaScript
  &lt;/span&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;if (umur &amp;gt; 18)
console.log(&quot;Dewasa&quot;);
console.log(&quot;Boleh punya SIM&quot;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Pemula mengira dua baris akan ikut kondisi &lt;/span&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;if.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Yang sebenarnya terjadi&lt;/b&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Hanya &lt;b&gt;1 baris pertama&lt;/b&gt; yang masuk kondisi&lt;/span&gt;&lt;span style=&quot;font-family: courier;&quot;&gt; if.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Penulisan yang benar&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;
    JavaScript
  &lt;/span&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;if (umur &amp;gt; 18) {
  console.log(&quot;Dewasa&quot;);
  console.log(&quot;Boleh punya SIM&quot;);
}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;5. Salah Menempatkan JavaScript di HTML&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Kesalahan klasik&lt;/b&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menulis JavaScript sebelum elemen HTML ada.&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;
    Html&lt;/span&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;&amp;lt;script&amp;gt;
document.getElementById(&quot;judul&quot;).innerHTML = &quot;Halo&quot;;
&amp;lt;/script&amp;gt;

&amp;lt;h1 id=&quot;judul&quot;&amp;gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Hasil:&lt;/b&gt; error atau tidak muncul apa-apa.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;b&gt;Penyebab&lt;/b&gt;&lt;br /&gt;JavaScript dijalankan sebelum HTML selesai dimuat.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;b&gt;Solusi paling aman untuk pemula&lt;/b&gt;&lt;br /&gt;Letakkan JavaScript &lt;b&gt;di bawah&lt;/b&gt; HTML:&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;
    Html&lt;/span&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;&amp;lt;h1 id=&quot;judul&quot;&amp;gt;&amp;lt;/h1&amp;gt;

&amp;lt;script&amp;gt;
document.getElementById(&quot;judul&quot;).innerHTML = &quot;Halo&quot;;
&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;6. Mengira JavaScript Sama dengan HTML atau CSS&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Kesalahan mindset&lt;/b&gt;&lt;br /&gt;Banyak pemula mencoba menulis seperti ini:&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;
    JavaScript
  &lt;/span&gt;&lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;&amp;lt;h1&amp;gt;Halo&amp;lt;/h1&amp;gt;  &lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Padahal JavaScript &lt;b&gt;bukan bahasa tampilan&lt;/b&gt;, tapi &lt;b&gt;bahasa logika&lt;/b&gt;.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;b&gt;Struktur dasar JavaScript itu berisi:&lt;/b&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Variabel&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Logika (if, else)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Perulangan&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Fungsi&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Manipulasi elemen HTML&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh benar:&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;
    JavaScript
  &lt;/span&gt;&lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;document.write(&quot;&amp;lt;h1&amp;gt;Halo&amp;lt;/h1&amp;gt;&quot;);  &lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;7. Lupa Bahwa Error Itu Normal&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Realita yang sering terjadi&lt;/b&gt;&lt;br /&gt;Pemula melihat error lalu langsung berpikir:&lt;br /&gt;&lt;blockquote&gt;“Saya tidak berbakat ngoding.”&lt;/blockquote&gt;&lt;br /&gt;Padahal:&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Programmer senior juga sering error&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Bedanya, mereka tahu cara membaca error&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;Contoh error penting:&lt;/span&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript
  &lt;/span&gt;&lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;Uncaught ReferenceError
Uncaught SyntaxError&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Itu bukan musuh, &lt;b&gt;tapi petunjuk kesalahan&lt;/b&gt;.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kesimpulan&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Struktur dasar JavaScript bukan soal hafalan sintaks, tapi soal:&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Urutan eksekusi&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Konsistensi penulisan&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Pemahaman cara kerja logika&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;Jika kamu sering error di awal, itu &lt;b&gt;bukan tanda gagal&lt;/b&gt;, tapi tanda kamu &lt;b&gt;sedang belajar dengan benar.&lt;/b&gt;&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript tidak sulit — yang sulit adalah melewati fase bingung pertama.&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://blog-cilik.blogspot.com/feeds/6846804872279492123/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/struktur-dasar-javascript-kesalahan.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/6846804872279492123'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/6846804872279492123'/><link rel='alternate' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/struktur-dasar-javascript-kesalahan.html' title='Struktur Dasar JavaScript: Kesalahan Umum yang Sering Terjadi pada Pemula'/><author><name>blogcilik</name><uri>http://www.blogger.com/profile/15754422881593101752</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-9024993991083531887.post-7989084175185423415</id><published>2026-01-19T20:41:00.000+07:00</published><updated>2026-01-19T20:41:00.512+07:00</updated><title type='text'>Sejarah ECMAScript: Standar yang Membuat JavaScript Tidak Berantakan</title><content type='html'>&lt;p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Di masa awal perkembangan web, JavaScript tumbuh dengan sangat cepat. Banyak browser membuat versinya sendiri-sendiri, sehingga kode JavaScript sering tidak konsisten dan sulit dijalankan di berbagai platform. &lt;b&gt;Dahulu, agar JavaScript tidak berantakan&lt;/b&gt;, akhirnya dibuatlah sebuah standar resmi bernama &lt;b&gt;ECMAScript&lt;/b&gt; oleh &lt;b&gt;ECMA International&lt;/b&gt;.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Artikel ini akan membahas mengapa ECMAScript lahir, apa perannya, dan mengapa hingga kini ECMAScript sangat penting bagi dunia web.&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;Kondisi JavaScript di Masa Awal&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Pada pertengahan tahun 1990-an, JavaScript dikembangkan oleh Netscape dengan nama awal &lt;b&gt;Mocha&lt;/b&gt;, lalu &lt;b&gt;LiveScript&lt;/b&gt;, dan akhirnya dikenal sebagai &lt;b&gt;JavaScript&lt;/b&gt;.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Masalah mulai muncul ketika:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Browser berbeda mengimplementasikan JavaScript dengan cara berbeda&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kode yang berjalan di Netscape belum tentu berjalan di Internet Explorer&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tidak ada aturan baku tentang sintaks dan perilaku JavaScript&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Akibatnya, kode JavaScript menjadi &lt;b&gt;tidak konsisten&lt;/b&gt;, &lt;b&gt;sulit dipelihara&lt;/b&gt;, &lt;b&gt;dan rawan error&lt;/b&gt;.&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;Lahirnya ECMAScript oleh ECMA International&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Untuk mengatasi kekacauan tersebut, pada tahun &lt;b&gt;1997&lt;/b&gt;, JavaScript distandarkan oleh sebuah organisasi internasional bernama &lt;b&gt;ECMA International&lt;/b&gt;.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Standar ini diberi nama &lt;b&gt;ECMAScript,&lt;/b&gt; diambil dari nama organisasi &lt;b&gt;ECMA&lt;/b&gt; (European Computer Manufacturers Association).&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tujuan utama ECMAScript adalah:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menyatukan aturan bahasa JavaScript&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menjadi acuan resmi bagi semua browser&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menghindari perbedaan implementasi yang ekstrem&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dengan adanya ECMAScript, semua browser &lt;b&gt;wajib mengikuti spesifikasi yang sama&lt;/b&gt;.&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;Apa Itu ECMAScript?&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;ECMAScript adalah spesifikasi atau standar bahasa&lt;/b&gt;, bukan browser dan bukan library.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Artinya:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;ECMAScript mendefinisikan&lt;b&gt; aturan bahasa JavaScript&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Browser seperti Chrome, Firefox, dan Edge mengimplementasikan standar ini&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript yang kita tulis saat ini sebenarnya adalah implementasi dari ECMAScript&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Singkatnya:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript adalah implementasi dari ECMAScript&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;Perkembangan Versi ECMAScript&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Seiring waktu, ECMAScript terus berkembang agar JavaScript semakin modern dan rapi.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Beberapa versi penting:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;ES3 (1999)&lt;/b&gt; → Versi yang lama bertahan sangat lama&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;ES5 (2009)&lt;/b&gt; → Mulai stabil dan banyak digunakan&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;ES6 / ES2015&lt;/b&gt; → Perubahan besar (let, const, arrow function, class)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;ES2016&lt;/b&gt; – &lt;b&gt;sekarang&lt;/b&gt; → Update rutin setiap tahun&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dengan standar ini, JavaScript menjadi:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Lebih konsisten&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Lebih mudah dibaca&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Lebih aman dan powerful&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;Mengapa ECMAScript Sangat Penting?&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tanpa ECMAScript:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript akan terpecah-pecah&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Developer harus menulis kode berbeda untuk setiap browser&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Web modern tidak akan berkembang pesat seperti sekarang&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dengan ECMAScript:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Satu kode bisa berjalan di banyak browser&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Framework seperti React, Vue, dan Angular bisa berkembang&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript menjadi bahasa utama web dan backend (Node.js)&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;Kesimpulan&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dahulu, agar JavaScript tidak berantakan dan tidak saling bertabrakan antar browser, dibuatlah standar resmi bernama &lt;b&gt;ECMAScript &lt;/b&gt;oleh &lt;b&gt;ECMA International&lt;/b&gt;.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Standar inilah yang membuat JavaScript menjadi bahasa yang rapi, konsisten, dan terus berkembang hingga saat ini.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tanpa ECMAScript, JavaScript mungkin tidak akan menjadi bahasa paling populer di dunia web seperti sekarang.&lt;/span&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='https://blog-cilik.blogspot.com/feeds/7989084175185423415/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/sejarah-ecmascript-standar-yang-membuat.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/7989084175185423415'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/7989084175185423415'/><link rel='alternate' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/sejarah-ecmascript-standar-yang-membuat.html' title='Sejarah ECMAScript: Standar yang Membuat JavaScript Tidak Berantakan'/><author><name>blogcilik</name><uri>http://www.blogger.com/profile/15754422881593101752</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-9024993991083531887.post-47129466753013751</id><published>2026-01-19T20:21:00.006+07:00</published><updated>2026-01-19T20:22:35.384+07:00</updated><title type='text'>Sekilas Sejarah JavaScript di Netscape Navigator</title><content type='html'>&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript &lt;b&gt;pertama kali dibuat tahun 1995 oleh Brendan Eich&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Awalnya bernama&lt;b&gt; Mocha&lt;/b&gt; → &lt;b&gt;LiveScript &lt;/b&gt;→ &lt;b&gt;JavaScript&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Pertama kali dipakai di &lt;b&gt;Netscape Navigator 2.0&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tujuan utama:&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Validasi form&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Interaksi sederhana (alert, confirm)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Manipulasi halaman secara sangat terbatas&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;⚠️ Saat itu belum ada DOM modern, belum ada &lt;/span&gt;&lt;span style=&quot;font-family: trebuchet;&quot;&gt;addEventListener&lt;/span&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: trebuchet;&quot;&gt;querySelector&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;, atau &lt;/span&gt;&lt;span style=&quot;font-family: trebuchet;&quot;&gt;let/const&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;.&lt;br /&gt;Cara Menulis JavaScript di Netscape Navigator&lt;br /&gt;&lt;/span&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;Script langsung di HTML&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript ditulis di dalam tag &lt;/span&gt;&lt;span style=&quot;font-family: trebuchet;&quot;&gt;&amp;lt;SCRIPT&amp;gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;Html&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;&amp;lt;SCRIPT LANGUAGE=&quot;JavaScript&quot;&amp;gt;
&amp;lt;!--
alert(&quot;Halo dari Netscape Navigator!&quot;);
//--&amp;gt;
&amp;lt;/SCRIPT&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;📌 &lt;/span&gt;&lt;b style=&quot;font-family: helvetica;&quot;&gt;Catatan penting:&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: trebuchet;&quot;&gt;LANGUAGE=&quot;JavaScript&quot;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt; digunakan, bukan &lt;/span&gt;&lt;span style=&quot;font-family: trebuchet;&quot;&gt;type&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Komentar &lt;/span&gt;&lt;span style=&quot;font-family: trebuchet;&quot;&gt;&amp;lt;!--&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt; dan &lt;/span&gt;&lt;span style=&quot;font-family: trebuchet;&quot;&gt;//--&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt; dipakai agar browser lama tidak error&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;Contoh Sintaks JavaScript Jadul (Era Netscape)&lt;/span&gt;&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;1. Alert Sederhana&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;Html&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;&amp;lt;SCRIPT LANGUAGE=&quot;JavaScript&quot;&amp;gt;
&amp;lt;!--
alert(&quot;Ini JavaScript versi lama&quot;);
//--&amp;gt;
&amp;lt;/SCRIPT&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;2. Manipulasi Dokumen dengan &lt;/span&gt;&lt;span style=&quot;color: #999999; font-family: trebuchet;&quot;&gt;document.write()&lt;/span&gt;&lt;/h3&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Ini sangat umum di Netscape&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;Html&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;&amp;lt;SCRIPT LANGUAGE=&quot;JavaScript&quot;&amp;gt;
&amp;lt;!--
document.write(&quot;Selamat datang di website Netscape!&quot;);
//--&amp;gt;
&amp;lt;/SCRIPT&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;⚠️ Sekarang document.write() tidak direkomendasikan, tapi dulu ini normal.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;3. Event Handler Inline (paling sering dipakai)&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;Html&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;&amp;lt;FORM&amp;gt;
&amp;lt;INPUT TYPE=&quot;button&quot; VALUE=&quot;Klik Saya&quot;
ONCLICK=&quot;alert(&#39;Tombol diklik!&#39;)&quot;&amp;gt;
&amp;lt;/FORM&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;✔ Tidak ada event listener terpisah&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;✔ Semua event langsung di atribut HTML&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;4. Validasi Form Sederhana&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;&lt;/p&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;Html&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;&amp;lt;FORM NAME=&quot;formku&quot;&amp;gt;
Nama: &amp;lt;INPUT TYPE=&quot;text&quot; NAME=&quot;nama&quot;&amp;gt;
&amp;lt;INPUT TYPE=&quot;button&quot; VALUE=&quot;Kirim&quot; ONCLICK=&quot;cekNama()&quot;&amp;gt;
&amp;lt;/FORM&amp;gt;

&amp;lt;SCRIPT LANGUAGE=&quot;JavaScript&quot;&amp;gt;
&amp;lt;!--
function cekNama() {
  if (document.formku.nama.value == &quot;&quot;) {
    alert(&quot;Nama tidak boleh kosong!&quot;);
  }
}
//--&amp;gt;
&amp;lt;/SCRIPT&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;

📌 &lt;span style=&quot;font-family: helvetica;&quot;&gt;Akses elemen pakai:

&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;document.formName.inputName&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;
5. Variabel &amp;amp; Tipe Data (sangat sederhana)&lt;/span&gt;&lt;/h3&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;var umur = 20;
var nama = &quot;Budi&quot;;
var aktif = true;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;✔ Hanya var&lt;br /&gt;❌ Tidak ada let, const, arrow function&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;6. Kondisi &amp;amp; Perulangan&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&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;&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;if (umur &amp;gt; 18) {
  alert(&quot;Dewasa&quot;);
}

for (i = 1; i &amp;lt;= 3; i++) {
  document.write(i + &quot;&amp;lt;br&amp;gt;&quot;);
}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Keterbatasan JavaScript di Netscape&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;❌ Tidak ada DOM modern&lt;br /&gt;❌ Tidak ada AJAX&lt;br /&gt;❌ Tidak ada JSON&lt;br /&gt;❌ Tidak ada module&lt;br /&gt;❌ Tidak ada async/await&lt;br /&gt;✔ Fokus pada interaksi ringan&lt;/span&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='https://blog-cilik.blogspot.com/feeds/47129466753013751/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/sekilas-sejarah-javascript-di-netscape.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/47129466753013751'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/47129466753013751'/><link rel='alternate' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/sekilas-sejarah-javascript-di-netscape.html' title='Sekilas Sejarah JavaScript di Netscape Navigator'/><author><name>blogcilik</name><uri>http://www.blogger.com/profile/15754422881593101752</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-9024993991083531887.post-3835149809490693912</id><published>2026-01-19T10:35:00.004+07:00</published><updated>2026-01-19T10:36:11.966+07:00</updated><title type='text'>Aturan Dasar Membuat Tampilan Website Interaktif Menggunakan JavaScript Murni</title><content type='html'>&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript murni (Vanilla JavaScript) adalah JavaScript tanpa bantuan library atau framework seperti jQuery, React, atau Vue. Menguasai JavaScript murni sangat penting karena menjadi fondasi utama dalam membangun website yang interaktif, ringan, dan mudah dikontrol sepenuhnya oleh developer.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Artikel ini membahas aturan dasar dan prinsip penting dalam membuat tampilan website interaktif menggunakan JavaScript murni.&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;1. Pahami Peran JavaScript dalam Website&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript berfungsi untuk:&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Merespons interaksi pengguna (klik, scroll, input)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mengubah konten HTML secara dinamis&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mengatur tampilan melalui manipulasi CSS&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mengontrol logika dan alur interaksi&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Aturan utama:&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript tidak menggantikan HTML dan CSS, tetapi melengkapinya.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Struktur yang sehat:&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;HTML&lt;/b&gt; → struktur&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;CSS &lt;/b&gt;→ tampilan&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;JavaScript&lt;/b&gt; → interaksi&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;2. Selalu Mulai dari HTML yang Rapi dan Semantik&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Interaktivitas yang baik dimulai dari HTML yang benar.&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Gunakan:&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;tag yang semantik (button, nav, section, article)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;atribut id dan class yang jelas&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh buruk:&lt;/span&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto; text-align: left;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;&amp;lt;div onclick=&quot;klik()&quot;&amp;gt;Klik&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;

Contoh lebih baik:

&lt;/span&gt;&lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto; text-align: left;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;&amp;lt;button id=&quot;btnKlik&quot;&amp;gt;Klik&amp;lt;/button&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Aturan:&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Jangan mencampur logika JavaScript langsung di HTML.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;3. Pisahkan File JavaScript dari HTML&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Gunakan file .js terpisah agar kode:&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;lebih bersih&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;mudah dirawat&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;lebih SEO &amp;amp; performa friendly&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh pemanggilan:&lt;/span&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto; text-align: left;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;&amp;lt;script src=&quot;script.js&quot; defer&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Gunakan atribut defer agar JavaScript dijalankan setelah HTML selesai dimuat.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;4. Gunakan Event Listener, Bukan Inline Event&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Hindari:&lt;/span&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto; text-align: left;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;&amp;lt;button onclick=&quot;aksi()&quot;&amp;gt;Klik&amp;lt;/button&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;
Gunakan:&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto; text-align: left;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;document.getElementById(&#39;btnKlik&#39;).addEventListener(&#39;click&#39;, function () {
  alert(&#39;Tombol diklik&#39;);
});&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Keuntungan:&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;kode lebih terstruktur&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;mudah dikembangkan&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;mendukung banyak event dalam satu elemen&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;5. Manipulasi DOM Secukupnya&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;DOM manipulation itu mahal secara performa.&lt;/span&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;b&gt;Aturan penting:&lt;/b&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Jangan memanipulasi DOM berulang-ulang tanpa perlu&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Simpan elemen dalam variabel&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh efisien:&lt;/span&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto; text-align: left;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;const box = document.querySelector(&#39;.box&#39;);
box.classList.add(&#39;active&#39;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Hindari query berulang di dalam loop jika tidak perlu.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;6. Gunakan Class untuk Mengatur Tampilan&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Jangan mengatur style langsung lewat JavaScript.&lt;br /&gt;❌ Buruk:&lt;/span&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;!--CODE BLOCK--&gt;&lt;/span&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto; text-align: left;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px; text-align: left;&quot;&gt;JavaScript&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;element.style.backgroundColor = &#39;red&#39;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;

✅ Baik:

&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto; text-align: left;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;element.classList.add(&#39;error&#39;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto; text-align: left;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;Css&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;.error {
  background-color: red;
}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Prinsip:&lt;/b&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript mengatur status, CSS mengatur tampilan.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;7. Buat Interaksi yang Responsif dan Masuk Akal&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Interaktif bukan berarti berlebihan.&lt;br /&gt;Perhatikan:&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;animasi tidak terlalu lama&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;feedback jelas saat klik / submit&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;tidak membuat pengguna bingung&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;Contoh interaksi sederhana:&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;tombol disable saat proses berjalan&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;loading indicator&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;perubahan teks setelah aksi&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;8. Gunakan Fungsi Kecil dan Jelas&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Hindari satu fungsi panjang dengan banyak tugas.&lt;br /&gt;Contoh:&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto; text-align: left;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;function showLoading() {}
function hideLoading() {}
function fetchData() {}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Aturan:&lt;/b&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Satu fungsi, satu tanggung jawab.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;9. Tangani Error dan Kondisi Tak Terduga&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Website interaktif harus tahan terhadap error.&lt;br /&gt;Contoh:&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;!--CODE BLOCK--&gt;&lt;/span&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto; text-align: left;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;const btn = document.getElementById(&#39;btn&#39;);
if (btn) {
  btn.addEventListener(&#39;click&#39;, aksi);
}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Jangan menganggap semua elemen selalu ada.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;10. Optimalkan untuk Performa dan Pengguna&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Beberapa prinsip penting:&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;gunakan requestAnimationFrame untuk animasi&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;debounce event scroll dan resize&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;hindari setInterval berlebihan&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;Website cepat = pengalaman pengguna lebih baik.&lt;br /&gt;&lt;/span&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;11. Uji di Berbagai Perangkat dan Browser&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript murni harus diuji:&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;mobile &amp;amp; desktop&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Chrome, Firefox, Edge&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;resolusi kecil&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;Gunakan console.log() dan DevTools untuk debugging.&lt;br /&gt;&lt;/span&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;Kesimpulan&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Membuat tampilan website interaktif dengan JavaScript murni bukan soal kode yang rumit, tetapi soal disiplin struktur, pemisahan tugas, dan fokus pada pengalaman pengguna.&lt;br /&gt;Jika kamu menguasai JavaScript murni dengan baik:&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;framework akan jauh lebih mudah dipelajari&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;website lebih ringan&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;kontrol penuh ada di tanganmu&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;Kuasai dasarnya, maka interaktivitas tingkat lanjut akan mengikuti.&lt;/span&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='https://blog-cilik.blogspot.com/feeds/3835149809490693912/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/aturan-dasar-membuat-tampilan-website.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/3835149809490693912'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/3835149809490693912'/><link rel='alternate' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/aturan-dasar-membuat-tampilan-website.html' title='Aturan Dasar Membuat Tampilan Website Interaktif Menggunakan JavaScript Murni'/><author><name>blogcilik</name><uri>http://www.blogger.com/profile/15754422881593101752</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-9024993991083531887.post-4173675955925217190</id><published>2026-01-18T10:15:00.005+07:00</published><updated>2026-01-18T10:18:49.738+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript Dasar"/><title type='text'>Belajar Web Programming JavaScript</title><content type='html'>&lt;p&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: helvetica;&quot;&gt;Web programming JavaScript adalah salah satu fondasi utama dalam pengembangan website modern. Hampir semua website interaktif saat ini menggunakan JavaScript untuk memberikan pengalaman pengguna yang dinamis, cepat, dan responsif. Dari sekadar validasi form hingga aplikasi web kompleks, JavaScript memiliki peran yang sangat besar.&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;Apa Itu Web Programming JavaScript?&lt;/span&gt;&lt;/h2&gt;&lt;p style=&quot;background-color: white; color: #222222;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript adalah bahasa pemrograman yang berjalan di sisi klien (client-side) maupun sisi server (server-side). Dalam konteks web programming, JavaScript digunakan untuk mengontrol perilaku halaman web agar dapat berinteraksi dengan pengguna secara real-time.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;&lt;b&gt;Fungsi Utama JavaScript di Web&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;background-color: white; color: #222222;&quot;&gt;&lt;li style=&quot;margin-left: 15px;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Membuat halaman web interaktif&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;margin-left: 15px;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Memanipulasi elemen HTML dan CSS&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;margin-left: 15px;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mengelola event seperti klik dan input&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;margin-left: 15px;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menghubungkan web dengan API&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;background-color: white; text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica; font-size: small;&quot;&gt;&lt;b&gt;JavaScript Client-Side vs Server-Side&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; color: #222222;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Pada client-side, JavaScript berjalan di browser pengguna untuk meningkatkan interaksi. Sementara pada server-side, JavaScript dijalankan menggunakan runtime seperti Node.js untuk mengelola logika backend.&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;Teknologi Pendukung JavaScript&lt;/span&gt;&lt;/h2&gt;&lt;p style=&quot;background-color: white; color: #222222;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dalam web programming JavaScript, ada beberapa teknologi yang umum digunakan bersama.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica; font-size: small;&quot;&gt;&lt;b&gt;HTML dan CSS&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; color: #222222;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;HTML berfungsi sebagai struktur, CSS sebagai tampilan, dan JavaScript sebagai logika interaksi. Ketiganya saling melengkapi dalam membangun website.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica; font-size: small;&quot;&gt;&lt;b&gt;Framework dan Library JavaScript&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; color: #222222;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Beberapa framework dan library populer antara lain:&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;background-color: white; color: #222222;&quot;&gt;&lt;li style=&quot;margin-left: 15px;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;React.js&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;margin-left: 15px;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Vue.js&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;margin-left: 15px;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Angular&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;margin-left: 15px;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;jQuery&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;background-color: white; color: #222222;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Framework ini membantu developer membangun aplikasi web dengan lebih cepat dan terstruktur.&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;background-color: white; text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;Keuntungan Menguasai Web Programming JavaScript&lt;/span&gt;&lt;/h2&gt;&lt;p style=&quot;background-color: white; color: #222222; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menguasai JavaScript memberikan banyak keuntungan, baik dari sisi karier maupun pengembangan produk.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;&lt;b&gt;Permintaan Tinggi di Dunia Kerja&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;&lt;b&gt;Fleksibel dan Multi-Platform&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; color: #222222; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript adalah salah satu skill paling dicari di industri IT karena hampir semua perusahaan digital membutuhkannya.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; color: #222222; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript dapat digunakan untuk web, backend, mobile app, bahkan desktop app dengan teknologi tertentu.&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;Tips Belajar Web Programming JavaScript&lt;/span&gt;&lt;/h2&gt;&lt;p style=&quot;background-color: white; color: #222222;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Belajar JavaScript sebaiknya dilakukan secara bertahap dan konsisten.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica; font-size: small;&quot;&gt;&lt;b&gt;Mulai dari Dasar&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; color: #222222;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Pahami konsep dasar seperti variabel, fungsi, dan kondisi sebelum masuk ke framework.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica; font-size: small;&quot;&gt;&lt;b&gt;Praktik dengan Proyek Nyata&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; color: #222222;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Membuat proyek sederhana seperti kalkulator atau to-do list akan mempercepat pemahaman.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica; font-size: small;&quot;&gt;&lt;b&gt;Kesimpulan&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; color: #222222;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Web programming JavaScript adalah skill wajib bagi siapa pun yang ingin terjun ke dunia pengembangan web. Dengan memahami dasar hingga penerapannya, JavaScript dapat membuka banyak peluang dan membantu membangun website yang modern dan profesional.&lt;/span&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='https://blog-cilik.blogspot.com/feeds/4173675955925217190/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/web-programming-javascript.html.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/4173675955925217190'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/4173675955925217190'/><link rel='alternate' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/web-programming-javascript.html.html' title='Belajar Web Programming JavaScript'/><author><name>blogcilik</name><uri>http://www.blogger.com/profile/15754422881593101752</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-9024993991083531887.post-1788265290665473119</id><published>2026-01-06T09:12:00.007+07:00</published><updated>2026-01-14T16:00:47.593+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript Dasar"/><title type='text'>JavaScript dan HTML: Cara Kerja, Hubungan, dan Contoh Penerapannya</title><content type='html'>&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Saat pertama kali belajar web development, saya sempat bingung membedakan &lt;/span&gt;&lt;b style=&quot;font-family: helvetica;&quot;&gt;HTML&lt;/b&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt; dan &lt;/span&gt;&lt;b style=&quot;font-family: helvetica;&quot;&gt;JavaScript&lt;/b&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;. Keduanya sering muncul bersamaan, tapi fungsinya ternyata sangat berbeda. Setelah sering ngoding dan trial error, barulah saya benar-benar paham bagaimana &lt;/span&gt;&lt;b style=&quot;font-family: helvetica;&quot;&gt;HTML dan JavaScript saling bekerja sama&lt;/b&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt; membangun sebuah website.&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Di artikel ini, kita akan bahas dari dasar sampai contoh sederhana agar kamu tidak bingung lagi.&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Apa Itu HTML?&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;HTML (&lt;b&gt;HyperText Markup Language&lt;/b&gt;) adalah &lt;b&gt;kerangka dasar&lt;/b&gt; sebuah halaman web.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;HTML digunakan untuk:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Membuat struktur halaman&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menampilkan teks, gambar, tombol, link&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menentukan elemen seperti header, paragraf, dan form&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Contoh HTML Sederhana&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;Html
&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
  &amp;lt;title&amp;gt;Belajar HTML&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
  &amp;lt;h1&amp;gt;Hello World&amp;lt;/h1&amp;gt;
  &amp;lt;p&amp;gt;Ini adalah paragraf.&amp;lt;/p&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tanpa HTML, browser tidak tahu apa yang harus ditampilkan.&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;Apa Itu JavaScript?&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript adalah &lt;b&gt;bahasa pemrograman&lt;/b&gt; yang membuat website menjadi &lt;b&gt;interaktif dan dinamis&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript digunakan untuk:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Merespons klik tombol&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mengubah isi HTML&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menampilkan popup&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Validasi form&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Membuat animasi&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Contoh JavaScript Sederhana&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;alert(&quot;Halo, selamat datang!&quot;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Saat pertama kali mencoba ini, saya langsung sadar:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;JavaScript adalah “nyawa” interaksi di website&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;Hubungan JavaScript dan HTML&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;HTML dan JavaScript &lt;b&gt;tidak bisa dipisahkan&lt;/b&gt; dalam web modern.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;HTML&lt;/b&gt; → Struktur&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;CSS&lt;/b&gt; → Tampilan&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;JavaScript&lt;/b&gt; → Interaksi&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript bekerja dengan cara &lt;b&gt;mengontrol dan memanipulasi elemen HTML&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Ilustrasi Sederhana&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Bayangkan website seperti rumah:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;HTML = rangka rumah&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;CSS = cat &amp;amp; dekorasi&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript = listrik &amp;amp; alat elektronik&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;Cara JavaScript Berinteraksi dengan HTML&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript berinteraksi dengan HTML melalui &lt;b&gt;DOM&lt;/b&gt; (&lt;b&gt;Document Object Model&lt;/b&gt;).&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Contoh Mengubah HTML dengan JavaScript&lt;/span&gt;&lt;/h3&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    Html&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;&amp;lt;p id=&quot;teks&quot;&amp;gt;Halo&amp;lt;/p&amp;gt;
&amp;lt;button onclick=&quot;ubahTeks()&quot;&amp;gt;Klik Saya&amp;lt;/button&amp;gt;

&amp;lt;script&amp;gt;
function ubahTeks() {
  document.getElementById(&quot;teks&quot;).innerHTML = &quot;Teks Berubah!&quot;;
}
&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Saat tombol diklik, JavaScript:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mencari elemen HTML&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mengubah isinya&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Browser menampilkan perubahan secara langsung&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;Cara Menyisipkan JavaScript ke dalam HTML&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Ada 3 &lt;b&gt;cara umum &lt;/b&gt;menyisipkan JavaScript ke HTML.&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;1. JavaScript di dalam Tag &amp;lt;script&amp;gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    Html&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;&amp;lt;script&amp;gt;
  console.log(&quot;Hello JavaScript&quot;);
&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;
2. JavaScript di File Terpisah&lt;/span&gt;&lt;/h3&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    Html&lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;&amp;lt;script src=&quot;script.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Cara ini paling direkomendasikan saat proyek mulai besar.&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;3. JavaScript Langsung di Atribut HTML&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    Html&lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;&amp;lt;button onclick=&quot;alert(&#39;Halo!&#39;)&quot;&amp;gt;Klik&amp;lt;/button&amp;gt;&lt;/div&gt;
&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;Kesalahan Umum Pemula Saat Menggabungkan HTML dan JavaScript&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Berdasarkan pengalaman pribadi, ini beberapa kesalahan yang sering terjadi:&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;JavaScript Dijalanakan Sebelum HTML Siap&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Solusi:&lt;/span&gt;&lt;/div&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    Html&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;&amp;lt;script&amp;gt;
document.addEventListener(&quot;DOMContentLoaded&quot;, function() {
  // kode JS
});
&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Salah ID atau Nama Elemen&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript case-sensitive, jadi:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;Html&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;id=&quot;Teks&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;
tidak sama dengan:&lt;/span&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;getElementById(&quot;teks&quot;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;Kenapa Harus Paham HTML Sebelum JavaScript?&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tanpa HTML:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript tidak punya objek untuk dikontrol&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Sulit memahami DOM&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Debugging jadi membingungkan&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Itulah kenapa di roadmap ini, HTML dan JavaScript dipelajari beriringan.&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;color: #999999;&quot;&gt;Penutup&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript dan HTML adalah &lt;b&gt;fondasi utama web development&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;HTML membentuk struktur, JavaScript memberi interaksi.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kalau kamu sudah paham hubungan keduanya:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Belajar DOM jadi lebih mudah&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Ngoding terasa lebih masuk akal&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tidak sekadar copy-paste kode&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Di artikel selanjutnya, kita akan mulai&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;system-ui, -apple-system, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Arial, &amp;quot;Noto Sans&amp;quot;, &amp;quot;Liberation Sans&amp;quot;, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;&quot; style=&quot;background-color: white; font-family: helvetica;&quot;&gt;&lt;a href=&quot;https://blog-cilik.blogspot.com/2026/01/keyword-penting-javascript.html&quot; target=&quot;_blank&quot;&gt;Keyword Penting JavaScript yang Wajib Dipahami&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://blog-cilik.blogspot.com/feeds/1788265290665473119/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/javascript-dan-html.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/1788265290665473119'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/1788265290665473119'/><link rel='alternate' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/javascript-dan-html.html' title='JavaScript dan HTML: Cara Kerja, Hubungan, dan Contoh Penerapannya'/><author><name>blogcilik</name><uri>http://www.blogger.com/profile/15754422881593101752</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-9024993991083531887.post-8682828072583351425</id><published>2026-01-05T11:31:00.003+07:00</published><updated>2026-01-06T11:05:55.130+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript Dasar"/><title type='text'>Keyword Penting JavaScript yang Wajib Dipahami Pemula</title><content type='html'>&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Keyword Penting JavaScript yang Wajib Dipahami Pemula&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Saat pertama kali belajar JavaScript, saya sempat bingung melihat banyak kata berwarna berbeda di editor kode.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Ternyata kata-kata tersebut adalah &lt;b&gt;keyword JavaScript&lt;/b&gt;, yaitu kata khusus yang punya arti tertentu dan &lt;b&gt;tidak boleh digunakan sembarangan&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Di artikel ini, kita akan membahas keyword JavaScript yang paling sering dipakai, khususnya untuk pemula.&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Apa Itu Keyword dalam JavaScript?&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Keyword JavaScript adalah &lt;b&gt;kata yang sudah dipesan oleh JavaScript &lt;/b&gt;dan memiliki fungsi khusus.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh keyword:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;var&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;let&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;const&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;if&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;for&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;function&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Pengalaman pribadi:&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Waktu awal belajar, saya pernah coba bikin variabel bernama function. Hasilnya? Error 😅&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Sejak itu saya sadar, keyword tidak boleh dipakai sebagai nama variabel.&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;Mengapa Keyword JavaScript Penting Dipelajari?&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Alasan kenapa keyword itu penting:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tidak boleh digunakan sebagai nama variabel&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menentukan alur logika program&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Digunakan hampir di semua kode JavaScript&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Membantu membaca dan memahami kode orang lain&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kalau kamu hafal keyword, proses belajar JavaScript akan jauh lebih cepat.&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;Daftar Keyword Penting JavaScript untuk Pemula&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Berikut keyword JavaScript yang paling sering muncul di tahap awal belajar.&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Keyword var, let, dan const&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Digunakan untuk membuat variabel.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;var nama = &quot;Budi&quot;;
let umur = 20;
const negara = &quot;Indonesia&quot;;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Penjelasan singkat:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;color: #999999;&quot;&gt;var&lt;/span&gt; → cara lama (jarang dipakai sekarang)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;color: #999999;&quot;&gt;let&lt;/span&gt; → variabel yang nilainya bisa diubah&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;color: #999999;&quot;&gt;const &lt;/span&gt;→ variabel tetap (tidak bisa diubah)&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Keyword if, else, dan else if&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Digunakan untuk &lt;b&gt;percabangan logika&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;if (umur &amp;gt;= 18) {
  console.log(&quot;Dewasa&quot;);
} else {
  console.log(&quot;Belum dewasa&quot;);
}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Sangat sering dipakai saat membuat validasi.&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Keyword for dan while&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Digunakan untuk perulangan (looping).&lt;/span&gt;&lt;/div&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript&lt;/div&gt;&lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;for (let i = 1; i &amp;lt;= 5; i++) {
  console.log(i);
}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Looping membantu kita menulis kode lebih singkat dan efisien.&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Keyword function&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Digunakan untuk membuat fungsi.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;function sapa() {
  console.log(&quot;Halo JavaScript!&quot;);
}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Fungsi membantu memecah kode menjadi bagian kecil yang rapi.&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Keyword return&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Digunakan untuk mengembalikan nilai dari fungsi.&lt;/span&gt;&lt;/div&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;function tambah(a, b) {
  return a + b;
}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tanpa return, fungsi tidak mengirimkan hasil apa pun.&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Keyword break dan continue&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Digunakan di dalam perulangan.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;for (let i = 1; i &amp;lt;= 5; i++) {
  if (i === 3) {
    break;
  }
  console.log(i);
}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;break → menghentikan loop&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;continue → melewati satu iterasi&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Keyword try, catch, dan finally&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Digunakan untuk menangani error.&lt;/span&gt;&lt;/div&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;try {
  console.log(data);
} catch (error) {
  console.log(&quot;Terjadi error&quot;);
}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Ini sangat membantu saat kode kita bermasalah tapi tidak ingin program langsung berhenti.&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;Keyword JavaScript Tidak Boleh Digunakan Sebagai Nama Variabel&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh yang salah ❌:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let function = &quot;tes&quot;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;
Contoh yang benar ✅:&lt;/span&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let fungsi = &quot;tes&quot;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;📌 Tips:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Gunakan nama variabel yang jelas dan tidak bentrok dengan keyword.&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;Tips Menghafal Keyword JavaScript&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Beberapa tips berdasarkan pengalaman ngoding:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Jangan dihafal semua sekaligus&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Praktik langsung di editor&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Gunakan berulang kali&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Baca dokumentasi dan contoh kode&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Percaya deh, makin sering ngoding, keyword akan hafal sendiri.&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kesimpulan&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Keyword JavaScript adalah &lt;b&gt;fondasi penting&lt;/b&gt; yang wajib dipahami oleh pemula.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dengan mengenal keyword seperti &lt;span style=&quot;color: #999999;&quot;&gt;var, let, const, if, for,&lt;/span&gt; dan &lt;span style=&quot;color: #999999;&quot;&gt;function&lt;/span&gt;, kamu sudah selangkah lebih dekat menjadi JavaScript developer.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Di roadmap berikutnya, keyword ini akan sering muncul, jadi pastikan kamu benar-benar memahaminya 😊&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='https://blog-cilik.blogspot.com/feeds/8682828072583351425/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/keyword-penting-javascript.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/8682828072583351425'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/8682828072583351425'/><link rel='alternate' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/keyword-penting-javascript.html' title='Keyword Penting JavaScript yang Wajib Dipahami Pemula'/><author><name>blogcilik</name><uri>http://www.blogger.com/profile/15754422881593101752</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-9024993991083531887.post-5340746055910726581</id><published>2026-01-04T22:57:00.001+07:00</published><updated>2026-01-06T11:06:41.574+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript Dasar"/><title type='text'>Tipe Data JavaScript Lengkap untuk Pemula (Pengalaman Nyata Saat Ngoding)</title><content type='html'>&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;h2 style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;Apa Itu Tipe Data dalam JavaScript?&lt;/span&gt;&lt;/h2&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Waktu pertama kali belajar JavaScript, saya sempat bingung kenapa hasil kode tidak sesuai harapan.&lt;/span&gt;&lt;div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Ternyata masalahnya &lt;b&gt;bukan di logika&lt;/b&gt;, tapi di &lt;b&gt;tipe data&lt;/b&gt; yang saya pakai.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dari situ saya sadar, memahami &lt;b&gt;tipe data JavaScript&lt;/b&gt; itu wajib hukumnya sebelum lanjut ke materi yang lebih jauh. Di artikel ini, saya akan jelaskan tipe data JavaScript &lt;b&gt;berdasarkan pengalaman ngoding langsung&lt;/b&gt;, lengkap dengan contoh sederhana.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tipe data adalah &lt;b&gt;jenis nilai&lt;/b&gt; yang disimpan di dalam sebuah variabel.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh sederhana:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let nama = &quot;Budi&quot;;
let umur = 20;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; white-space: pre-wrap;&quot;&gt;khkkkklll&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&quot;Budi&quot; → tipe data &lt;b&gt;String&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;20 → tipe data &lt;b&gt;Number&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Saat ngoding, JavaScript akan memperlakukan data berbeda tergantung tipenya. Kalau salah tipe, hasilnya bisa bikin pusing 😅&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;Jenis-Jenis Tipe Data JavaScript&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Secara umum, tipe data JavaScript terbagi menjadi:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Primitive&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Non-Primitive (Reference Type)&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;Tipe Data Primitive JavaScript&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;String&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;String adalah teks yang ditulis dengan tanda kutip.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let pesan = &quot;Belajar JavaScript itu seru&quot;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;📌 Pengalaman saya:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Pernah lupa pakai tanda kutip, hasilnya error dan saya kira JavaScript-nya rusak 😅&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Number&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Number digunakan untuk angka, baik bulat maupun desimal.&lt;/span&gt;&lt;/div&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let nilai = 90;
let berat = 55.5;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;📌 Di JavaScript, &lt;b&gt;tidak ada int atau float&lt;/b&gt;, semuanya dianggap Number.&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Boolean&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Boolean hanya punya dua nilai:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;true&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;false&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let isLogin = true;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;📌 Biasanya saya pakai Boolean untuk:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;validasi form&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;pengecekan kondisi (if)&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Undefined&lt;/span&gt;&lt;/h3&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;undefined berarti &lt;b&gt;variabel ada, tapi belum diberi nilai&lt;/b&gt;.&amp;nbsp;&lt;/span&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let alamat;
console.log(alamat); // undefined&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;📌&lt;span style=&quot;font-family: helvetica;&quot;&gt; Ini sering muncul tanpa sengaja saat lupa mengisi variabel.&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Null&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;null artinya kosong secara sengaja.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let dataUser = null;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;📌 &lt;span style=&quot;font-family: helvetica;&quot;&gt;Bedanya dengan undefined:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;undefined → tidak sengaja&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;null → sengaja dikosongkan&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Symbol (Sekilas)&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Symbol jarang dipakai pemula, tapi tetap penting diketahui.&lt;/span&gt;&lt;/div&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let id = Symbol(&quot;id&quot;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;📌 &lt;span style=&quot;font-family: helvetica;&quot;&gt;Biasanya dipakai untuk nilai unik agar tidak bentrok.&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;Tipe Data Non-Primitive (Reference Type)&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Array&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Array digunakan untuk menyimpan &lt;b&gt;banyak data dalam satu variabel&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let buah = [&quot;Apel&quot;, &quot;Jeruk&quot;, &quot;Mangga&quot;];&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;📌 &lt;span style=&quot;font-family: helvetica;&quot;&gt;Waktu pertama kali pakai array, saya baru sadar betapa ribetnya variabel kalau tidak pakai array.&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Object&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Object menyimpan data dalam bentuk key dan value.&lt;/span&gt;&lt;/div&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let user = {
  nama: &quot;Andi&quot;,
  umur: 21,
  aktif: true
};&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;📌 &lt;span style=&quot;font-family: helvetica;&quot;&gt;Object ini sering saya pakai saat bikin:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;data user&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;konfigurasi&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;response API&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Function (Termasuk Tipe Data)&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Function di JavaScript juga dianggap tipe data.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;function sapa() {
  console.log(&quot;Halo!&quot;);
}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;📌&lt;span style=&quot;font-family: helvetica;&quot;&gt; Ini unik di JavaScript dan sering bikin kaget pemula.&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;Cara Mengetahui Tipe Data (typeof)&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Saat bingung dengan tipe data, saya sering pakai &lt;i&gt;&lt;span style=&quot;color: #666666;&quot;&gt;typeof.&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;typeof &quot;Halo&quot;;   // string
typeof 10;       // number
typeof true;     // boolean&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;

📌 &lt;span style=&quot;font-family: helvetica;&quot;&gt;Catatan penting:

&lt;/span&gt;&lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;typeof null; // object (bug lama JavaScript)  &lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Ini bukan salah kamu, tapi memang bug bawaan JavaScript 😄&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;Kesalahan Umum Pemula Saat Pakai Tipe Data&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Berdasarkan pengalaman saya, ini kesalahan yang sering terjadi:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mengira &quot;10&quot; sama dengan 10&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Lupa tanda kutip pada string&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Bingung antara null dan undefined&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Salah mengolah data array dan object&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kesimpulan&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Memahami tipe data JavaScript itu &lt;b&gt;pondasi utama saat ngoding&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Saya sendiri baru benar-benar nyaman ngoding setelah paham:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;kapan pakai string&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;kapan pakai number&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;kapan pakai array atau object&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kalau kamu masih pemula, &lt;b&gt;jangan buru-buru lanjut ke framework&lt;/b&gt; sebelum benar-benar paham tipe data.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://blog-cilik.blogspot.com/feeds/5340746055910726581/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/tipe-data-javascript-lengkap-untuk-pemula.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/5340746055910726581'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/5340746055910726581'/><link rel='alternate' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/tipe-data-javascript-lengkap-untuk-pemula.html' title='Tipe Data JavaScript Lengkap untuk Pemula (Pengalaman Nyata Saat Ngoding)'/><author><name>blogcilik</name><uri>http://www.blogger.com/profile/15754422881593101752</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-9024993991083531887.post-4012538199411729943</id><published>2026-01-04T19:44:00.004+07:00</published><updated>2026-01-04T19:44:41.149+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript Dasar"/><title type='text'>Case Sensitive pada JavaScript: Pengertian, Contoh, dan Kesalahan Umum</title><content type='html'>&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;🧩&amp;nbsp;Case Sensitive pada JavaScript&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Saat belajar JavaScript, kamu mungkin pernah mengalami error padahal kode terlihat benar. Salah satu penyebab paling umum adalah &lt;b&gt;case sensitive&lt;/b&gt;. JavaScript sangat memperhatikan &lt;b&gt;huruf besar dan huruf kecil&lt;/b&gt;, sehingga perbedaan kecil bisa menyebabkan error.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Artikel ini akan membahas apa itu case sensitive, contoh penerapannya, serta kesalahan yang sering dilakukan pemula.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;🧩&amp;nbsp;Apa Itu Case Sensitive?&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Case sensitive&lt;/b&gt; adalah kondisi di mana bahasa pemrograman membedakan huruf &lt;b&gt;besar (uppercase)&lt;/b&gt; dan &lt;b&gt;kecil (lowercase)&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Di JavaScript:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;nama&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Nama&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;NAMA&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;👉 &lt;b&gt;Dianggap sebagai tiga hal yang berbeda&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;🧩&amp;nbsp;&lt;span style=&quot;color: #666666;&quot;&gt;Contoh Case Sensitive pada JavaScript&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Case Sensitive pada Variabel&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let nama = &quot;Andi&quot;;
let Nama = &quot;Budi&quot;;

console.log(nama);
console.log(Nama);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;

📌 Hasilnya:&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;color: #999999;&quot;&gt;nama&lt;/span&gt; → Andi&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: #999999;&quot;&gt;Nama&lt;/span&gt; → Budi&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;Walaupun mirip, JavaScript menganggapnya &lt;b&gt;dua variabel berbeda&lt;/b&gt;.&lt;/div&gt;&lt;/span&gt;&lt;h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;🧩&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;Case Sensitive pada Function&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;function sapa() {
  console.log(&quot;Halo!&quot;);
}

Sapa(); // Error&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;❌ &lt;span style=&quot;font-family: helvetica;&quot;&gt;Error terjadi karena:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Function yang dibuat bernama &lt;span style=&quot;color: #999999;&quot;&gt;sapa&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Yang dipanggil &lt;span style=&quot;color: #666666;&quot;&gt;Sapa&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Huruf &lt;b&gt;S&lt;/b&gt; besar dan kecil berbeda.&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;🧩&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;Case Sensitive pada Keyword JavaScript&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Keyword JavaScript &lt;b&gt;harus ditulis dengan huruf kecil&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;let angka = 10;

If (angka &amp;gt; 5) {
  console.log(&quot;Benar&quot;);
}&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;❌ Salah&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Penulisan yang benar:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;if (angka &amp;gt; 5) {
  console.log(&quot;Benar&quot;);
}&lt;/div&gt;
&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;🧩&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;Contoh Kesalahan Umum Akibat Case Sensitive&lt;/span&gt;&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Salah Nama Variabel&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;let totalHarga = 1000;
console.log(totalharga);&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;❌&lt;span style=&quot;font-family: helvetica;&quot;&gt; Error karena:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;totalHarga ≠ totalharga&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Salah Penulisan Method&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;console.Log(&quot;Hello&quot;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;❌ Salah&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Penulisan yang benar:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;console.log(&quot;Hello&quot;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;🧩&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;Tips Menghindari Error Case Sensitive&lt;/span&gt;&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Gunakan Konsisten Penamaan&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Gunakan &lt;b&gt;camelCase&lt;/b&gt; untuk variabel dan function&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;let totalBelanja;
function hitungTotal() {}&lt;/div&gt;
&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;🧩&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Biasakan Auto Complete Editor&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Gunakan editor seperti &lt;b&gt;VS Code&lt;/b&gt; agar:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Nama variabel otomatis&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mengurangi salah ketik huruf besar/kecil&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;🧩&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;Perhatikan Error Message di Console&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript biasanya menampilkan pesan seperti:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;is not defined&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;is not a function&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Pesan ini sering muncul karena kesalahan case sensitive.&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;🧩&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;Kesimpulan&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript adalah bahasa pemrograman yang &lt;b&gt;case sensitive&lt;/b&gt;, sehingga:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Huruf besar dan kecil &lt;b&gt;sangat berpengaruh&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Salah satu penyebab error paling umum bagi pemula&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Harus konsisten dalam penulisan kode&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dengan memahami konsep ini, kamu bisa menghindari banyak error kecil namun membingungkan.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://blog-cilik.blogspot.com/feeds/4012538199411729943/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/case-sensitive-pada-javascript.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/4012538199411729943'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/4012538199411729943'/><link rel='alternate' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/case-sensitive-pada-javascript.html' title='Case Sensitive pada JavaScript: Pengertian, Contoh, dan Kesalahan Umum'/><author><name>blogcilik</name><uri>http://www.blogger.com/profile/15754422881593101752</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-9024993991083531887.post-6064468967768957242</id><published>2026-01-04T17:03:00.002+07:00</published><updated>2026-01-04T17:03:44.311+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript Dasar"/><title type='text'>Aturan Penulisan JavaScript: Panduan Dasar agar Kode Rapi &amp; Bebas Error</title><content type='html'>&lt;div&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;&lt;b&gt;Pendahuluan&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript adalah bahasa pemrograman yang &lt;b&gt;sangat fleksibel&lt;/b&gt;, namun jika tidak mengikuti aturan penulisan yang benar, kode bisa menjadi sulit dibaca dan rawan error.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Pada artikel ini, kita akan membahas &lt;b&gt;aturan penulisan JavaScript &lt;/b&gt;yang wajib dipahami oleh pemula agar kode lebih &lt;b&gt;rapi, konsisten, dan profesional.&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;🧩&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;Aturan Dasar Penulisan JavaScript&lt;/span&gt;&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;JavaScript Bersifat Case Sensitive&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript membedakan &lt;b&gt;huruf besar dan kecil.&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let nama = &quot;Andi&quot;;
let Nama = &quot;Budi&quot;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;nama dan Nama dianggap variabel yang berbeda.&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Penulisan Statement di JavaScript&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Setiap perintah dalam JavaScript disebut &lt;b&gt;statement.&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;console.log(&quot;Belajar JavaScript&quot;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Umumnya satu statement ditulis dalam satu baris.&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Penggunaan Titik Koma (;)&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Titik koma digunakan untuk mengakhiri statement.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let umur = 20;
console.log(umur);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Titik koma opsional, tetapi sangat disarankan untuk menghindari bug.&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;🧩 &lt;span style=&quot;color: #666666;&quot;&gt;Aturan Penulisan Variabel&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Nama Variabel Harus Jelas&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Gunakan nama variabel yang mudah dipahami.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let totalHarga;
let jumlahSiswa;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;
❌ Hindari:
&lt;/span&gt;&lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let x;
let a1;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Tidak Boleh Menggunakan Kata Kunci&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Variabel &lt;b&gt;tidak boleh&lt;/b&gt; menggunakan keyword JavaScript.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;❌ Contoh salah:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let function = &quot;test&quot;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Aturan Penamaan Variabel&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tidak boleh diawali angka&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tidak boleh menggunakan spasi&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Boleh menggunakan _ dan $&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let nama_lengkap;
let $harga;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;🧩 &lt;span style=&quot;color: #666666;&quot;&gt;Aturan Penulisan Blok Kode&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Penggunaan Kurung Kurawal {}&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Blok kode digunakan pada &lt;/span&gt;&lt;span style=&quot;color: #666666; font-family: inherit;&quot;&gt;if, for, function&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;, dll.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;if (nilai &amp;gt; 70) {
  console.log(&quot;Lulus&quot;);
}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Indentasi Kode&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Indentasi membuat kode lebih rapi dan mudah dibaca.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;function sapa() {
  let nama = &quot;Ani&quot;;
  console.log(nama);
}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;

Gunakan &lt;b&gt;2 atau 4 spasi secara konsisten&lt;/b&gt;.&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;🧩 &lt;span style=&quot;color: #666666;&quot;&gt;Aturan Penulisan Komentar&lt;/span&gt;&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999;&quot;&gt;Komentar Satu Baris&lt;/span&gt;&lt;/h3&gt;&lt;/span&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;// Ini komentar satu baris&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;
Komentar Multi Baris&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;/*
Ini komentar
lebih dari satu baris
*/&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Komentar berguna untuk:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menjelaskan kode&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Catatan pribadi&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menonaktifkan kode sementara&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;🧩 &lt;span style=&quot;color: #666666;&quot;&gt;Aturan Penulisan String&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menggunakan Petik &lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;(&lt;span&gt;&#39; &quot;&lt;/span&gt; `)&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript mendukung:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Petik satu &lt;span style=&quot;color: #666666;&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Petik dua&lt;span style=&quot;color: #666666;&quot;&gt; &quot;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Backtick&lt;span style=&quot;color: #666666;&quot;&gt; `&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let nama = &quot;Budi&quot;;
let salam = &#39;Halo&#39;;
let pesan = `Halo ${nama}`;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;🧩 &lt;span style=&quot;color: #666666;&quot;&gt;Praktik Terbaik dalam Menulis JavaScript&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Gunakan Kode yang Konsisten&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Gaya penulisan sama&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Spasi rapi&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Nama variabel jelas&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Hindari Kode Berantakan&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kode rapi:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let a = 10;
let b = 20;
let hasil = a + b;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;

Kode tidak rapi:

&lt;/span&gt;&lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let a=10;let b=20;let hasil=a+b;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Kesimpulan&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Memahami &lt;b&gt;aturan penulisan JavaScript&lt;/b&gt; adalah langkah penting sebelum masuk ke materi yang lebih lanjut. Dengan menulis kode yang rapi, konsisten, dan sesuai aturan, kamu akan:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Lebih mudah memahami kode sendiri&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menghindari error&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Terlihat lebih profesional&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://blog-cilik.blogspot.com/feeds/6064468967768957242/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/aturan-penulisan-javascript.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/6064468967768957242'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/6064468967768957242'/><link rel='alternate' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/aturan-penulisan-javascript.html' title='Aturan Penulisan JavaScript: Panduan Dasar agar Kode Rapi &amp; Bebas Error'/><author><name>blogcilik</name><uri>http://www.blogger.com/profile/15754422881593101752</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-9024993991083531887.post-7220788389837508808</id><published>2026-01-03T15:37:00.005+07:00</published><updated>2026-01-04T11:24:37.476+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript Dasar"/><title type='text'>Console.log dan Debug Awal JavaScript</title><content type='html'>&lt;h2 style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;Pendahuluan&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Saat belajar JavaScript, kamu pasti pernah bertanya:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica; font-size: x-small;&quot;&gt;&lt;blockquote&gt;“Kenapa kodenya tidak jalan, padahal tidak ada error?”&lt;/blockquote&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Di sinilah &lt;b&gt;console.log dan teknik debug awal&lt;/b&gt; menjadi senjata utama seorang programmer. Hampir semua developer JavaScript — dari pemula sampai profesional — menggunakan &lt;/span&gt;&lt;span style=&quot;color: #666666; font-family: courier;&quot;&gt;console.log()&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt; setiap hari.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Pada artikel ini, kamu akan belajar:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Apa itu &lt;/span&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;console.log&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Cara menggunakannya&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Fungsi console lain yang berguna&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Cara debug error JavaScript paling dasar&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;Apa Itu console.log?&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;console.log()&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt; adalah perintah JavaScript untuk &lt;b&gt;menampilkan informasi ke Console browser.&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Console biasanya digunakan untuk:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Melihat nilai variabel&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mengecek alur program&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mencari kesalahan (bug)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Memahami proses eksekusi kode&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Console &lt;b&gt;tidak tampil di halaman web&lt;/b&gt;, tapi muncul di &lt;b&gt;Developer Tools &lt;/b&gt;browser.&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;Cara Membuka Console Browser&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Gunakan shortcut berikut:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Chrome / Edge pakai&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;Ctrl + Shift + I&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt; → Tab &lt;b&gt;Console&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Firefox pakai&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;Ctrl + Shift + K&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mac pakai&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;Cmd + Option + I&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;Contoh Dasar Console.log&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;console.log(&quot;Halo Dunia!&quot;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;

Hasil di console:

&lt;/span&gt;&lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;Halo Dunia!&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;
Menampilkan Nilai Variabel
&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let nama = &quot;BlokCilik&quot;;
let umur = 10;

console.log(nama);
console.log(umur);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;

Output:

&lt;/span&gt;&lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;BlokCilik
10&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;👉 Ini sangat berguna untuk memastikan &lt;b&gt;isi variabel sudah benar atau belum.&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Debug Sederhana Menggunakan &lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;console.log&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh kode bermasalah:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let hasil = 10 + x;
console.log(hasil);
Error:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;

Error:&lt;/span&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;ReferenceError: x is not defined&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dengan console, kamu langsung tahu:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Variabel x belum dideklarasikan&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Lokasi error ditampilkan jelas&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;Menampilkan Banyak Data Sekaligus&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let a = 5;
let b = 10;

console.log(&quot;Nilai a:&quot;, a, &quot;Nilai b:&quot;, b);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;

Output:&lt;/span&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;Nilai a: 5 Nilai b: 10&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;Jenis Console Lain yang Berguna&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Selain &lt;/span&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;console.log&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;, JavaScript punya beberapa console penting:&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;console.error()&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menampilkan pesan error:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;console.error(&quot;Terjadi kesalahan!&quot;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;console.warn()&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menampilkan peringatan:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;console.warn(&quot;Ini hanya peringatan&quot;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;console.info()&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menampilkan informasi:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;console.info(&quot;Informasi program&quot;);&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;Debug Alur Program&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Gunakan &lt;/span&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;console.log&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt; untuk mengecek apakah kode dijalankan atau tidak.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;console.log(&quot;Program dimulai&quot;);

let angka = 5;

if (angka &amp;gt; 3) {
  console.log(&quot;Angka lebih besar dari 3&quot;);
}

console.log(&quot;Program selesai&quot;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dengan cara ini, kamu bisa:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mengetahui kode berhenti di bagian mana&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Melihat logika berjalan sesuai rencana atau tidak&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;Kesalahan Umum Pemula&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;❌ Mengira console.log tampil di halaman web&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;❌ Lupa membuka tab Console&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;❌ Tidak menghapus console.log setelah selesai debug&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;👉 Pada project besar, console berlebihan bisa membuat kode berantakan.&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kapan Harus Menggunakan &lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span&gt;console.log&lt;/span&gt;&lt;span&gt;?&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Gunakan saat:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Belajar JavaScript&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mengecek nilai variabel&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mencari bug&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Memahami alur kode&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kurangi penggunaan saat:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Website sudah production&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kode siap dipublikasikan&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;Kesimpulan&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;console.log&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt; adalah &lt;b&gt;alat debug paling dasar dan paling penting &lt;/b&gt;dalam JavaScript.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tanpa console, kamu akan kesulitan memahami apa yang terjadi di balik layar.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;💡&lt;b&gt; Ingat:&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kalau kodenya error, jangan panik — buka console!&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://blog-cilik.blogspot.com/feeds/7220788389837508808/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/console-log-dan-debug-awal-javascript.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/7220788389837508808'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/7220788389837508808'/><link rel='alternate' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/console-log-dan-debug-awal-javascript.html' title='Console.log dan Debug Awal JavaScript'/><author><name>blogcilik</name><uri>http://www.blogger.com/profile/15754422881593101752</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-9024993991083531887.post-6349860344474808720</id><published>2026-01-03T11:01:00.001+07:00</published><updated>2026-01-03T11:01:17.502+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript Dasar"/><title type='text'>Comment di JavaScript: Fungsi, Jenis, dan Cara Penggunaan yang Benar</title><content type='html'>&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Apa Itu Comment di JavaScript
&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;div&gt;Comment di JavaScript adalah &lt;b&gt;baris kode yang tidak dijalankan oleh program&lt;/b&gt;, melainkan digunakan untuk memberi &lt;b&gt;catatan atau penjelasan&lt;/b&gt; pada kode.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Comment sangat penting terutama saat:&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Belajar JavaScript&lt;/li&gt;&lt;li&gt;Bekerja dalam tim&lt;/li&gt;&lt;li&gt;Membaca ulang kode lama&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;Google juga menyukai kode yang &lt;b&gt;rapi dan mudah dipahami&lt;/b&gt;, terutama pada artikel tutorial.&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Fungsi Comment di JavaScript&lt;/h2&gt;&lt;div&gt;Berikut beberapa fungsi utama comment:&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Menjelaskan tujuan kode&lt;/li&gt;&lt;li&gt;Memberi catatan penting untuk programmer lain&lt;/li&gt;&lt;li&gt;Menonaktifkan sementara kode tertentu (debugging)&lt;/li&gt;&lt;li&gt;Membuat kode lebih rapi dan terstruktur&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;📌 Kesimpulan:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;Kode tanpa comment akan sulit dipahami, terutama jika jumlah barisnya banyak.&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Jenis Comment di JavaScript&lt;/h2&gt;&lt;div&gt;Di JavaScript, ada &lt;b&gt;2 jenis comment utama&lt;/b&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;1. Single-Line Comment&lt;/h3&gt;&lt;div&gt;Single-line comment digunakan untuk &lt;b&gt;satu baris komentar&lt;/b&gt;.&lt;/div&gt;&lt;div&gt;Contoh:&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;// Ini adalah comment satu baris
let nama = &quot;BlokCilik&quot;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;📝 Keterangan:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Diawali dengan //&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Semua teks setelah // tidak akan dijalankan&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;2. Multi-Line Comment&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Multi-line comment digunakan untuk &lt;b&gt;lebih dari satu baris.&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;/*
Ini adalah comment
lebih dari satu baris
di JavaScript
*/
let umur = 10;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;📝 Keterangan:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dimulai dengan /*&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Diakhiri dengan */&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh Penggunaan Comment di JavaScript&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Comment sering digunakan untuk menjelaskan logika program.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;// Menyimpan nilai panjang dan lebar
let panjang = 10;
let lebar = 5;

// Menghitung luas persegi panjang
let luas = panjang * lebar;

console.log(luas);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dengan comment, orang lain akan langsung paham &lt;b&gt;maksud dari setiap bagian kode&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Comment untuk Debugging&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Saat terjadi error, comment bisa digunakan &lt;b&gt;untuk menonaktifkan sementara kode&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let angka1 = 10;
// let angka2 = 5;

console.log(angka1);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Teknik ini sering digunakan programmer saat mencari bug.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kesalahan Umum Saat Menggunakan Comment&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Beberapa kesalahan yang sering dilakukan pemula:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Terlalu banyak comment yang tidak perlu&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Comment tidak sesuai dengan isi kode&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menjadikan comment sebagai pengganti penulisan kode yang jelas&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;📌 &lt;b&gt;Tips:&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Comment harus &lt;b&gt;menjelaskan “kenapa”&lt;/b&gt;, bukan hanya “apa”.&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kesimpulan&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Comment di JavaScript adalah bagian penting dalam penulisan kode yang baik. Dengan memahami jenis dan cara penggunaannya, kode akan lebih mudah dipahami, dirawat, dan dikembangkan.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;💡 Biasakan menulis comment sejak awal belajar JavaScript.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
 
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://blog-cilik.blogspot.com/feeds/6349860344474808720/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/comment-di-javascript-fungsi-jenis-dan.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/6349860344474808720'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/6349860344474808720'/><link rel='alternate' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/comment-di-javascript-fungsi-jenis-dan.html' title='Comment di JavaScript: Fungsi, Jenis, dan Cara Penggunaan yang Benar'/><author><name>blogcilik</name><uri>http://www.blogger.com/profile/15754422881593101752</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-9024993991083531887.post-5041396690965774233</id><published>2026-01-03T08:45:00.000+07:00</published><updated>2026-01-03T08:48:36.719+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript Dasar"/><title type='text'>Statement dan Expression dalam JavaScript</title><content type='html'>&lt;div&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;Memahami Perintah dan Nilai Dasar Program JavaScript&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Saat mulai belajar JavaScript, kamu akan sering menemui dua istilah penting: &lt;b&gt;statement&lt;/b&gt; dan &lt;b&gt;expression&lt;/b&gt;. Keduanya adalah fondasi utama dalam menulis kode JavaScript. Jika kamu belum memahaminya, program bisa terasa membingungkan.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tenang 🙂&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Di artikel ini kita akan membahasnya &lt;b&gt;pelan-pelan dan dengan contoh sederhana&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;Apa Itu Statement dalam JavaScript?&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Statement &lt;/b&gt;adalah &lt;b&gt;perintah&lt;/b&gt; yang dijalankan oleh JavaScript.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;👉 Ibarat bahasa manusia, statement itu seperti &lt;b&gt;kalimat perintah&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Contoh Statement Sederhana&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let nama = &quot;Andi&quot;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kode di atas adalah &lt;b&gt;statement&lt;/b&gt;, karena:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript &lt;b&gt;diperintah&lt;/b&gt; untuk membuat variabel&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Lalu menyimpan nilai &lt;/span&gt;&lt;span style=&quot;color: #999999; font-family: courier;&quot;&gt;&quot;Andi&quot;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;color: #999999;&quot;&gt; &lt;/span&gt;ke dalamnya&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh lainnya:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;console.log(&quot;Halo Dunia&quot;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Artinya:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript, tampilkan teks &quot;Halo Dunia&quot; ke console.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;Jenis-Jenis Statement dalam JavaScript&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Berikut beberapa statement yang paling sering digunakan pemula:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;1. Declaration Statement&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Digunakan untuk membuat variabel.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let umur = 20;
const pi = 3.14;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;2. Assignment Statement&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Memberi atau mengubah nilai variabel.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;umur = 21;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;3. Conditional Statement&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Digunakan untuk pengambilan keputusan.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;if (umur &amp;gt;= 18) {
  console.log(&quot;Sudah dewasa&quot;);
}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;4. Loop Statement&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Digunakan untuk perulangan.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;for (let i = 1; i &amp;lt;= 5; i++) {
  console.log(i);
}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;Apa Itu Expression dalam JavaScript?&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Expression&lt;/b&gt; adalah &lt;b&gt;kode yang menghasilkan nilai&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;👉 Jika statement adalah &lt;b&gt;perintah&lt;/b&gt;, maka expression adalah &lt;b&gt;sesuatu yang bisa dihitung atau dievaluasi.&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Contoh Expression&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;5 + 3&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Hasilnya adalah:&lt;/span&gt;&lt;br /&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;8&lt;/div&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;
Contoh lain:
&lt;/span&gt;&lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;umur &amp;gt; 18&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;

Hasilnya:

&lt;/span&gt;&lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;Expression di Dalam Statement&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dalam JavaScript, &lt;b&gt;expression sering berada di dalam statement.&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let hasil = 10 * 2;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Penjelasan:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;10 * 2 → &lt;b&gt;expression&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;let hasil = ... → &lt;b&gt;statement&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh lain:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;if (nilai &amp;gt;= 75) {
  console.log(&quot;Lulus&quot;);
}
nilai &amp;gt;= 75 → expression
if (...) { ... } → statement&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;Jenis-Jenis Expression&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;1. Arithmetic Expression&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;10 + 5
20 - 3
4 * 2
8 / 2&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;2. Comparison Expression

&lt;/b&gt;&lt;/span&gt;&lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;5 &amp;gt; 3
10 == 10
7 !== 5&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;3. Logical Expression
&lt;/b&gt;&lt;/span&gt;&lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;true &amp;amp;&amp;amp; false
true || false
!true&lt;/div&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;4. Function Expression

&lt;/b&gt;&lt;/span&gt;&lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let sapa = function() {
  return &quot;Halo!&quot;;
};&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Memahami &lt;b&gt;statement dan expression &lt;/b&gt;akan membantumu:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Lebih mudah membaca kode orang lain&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tidak bingung saat error muncul&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Lebih cepat paham kondisi, logika, dan perulangan&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Siap masuk ke materi JavaScript tingkat lanjut&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Kesimpulan&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Statement &lt;/b&gt;adalah perintah yang dijalankan JavaScript&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Expression &lt;/b&gt;adalah kode yang menghasilkan nilai&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Keduanya &lt;b&gt;saling berkaitan &lt;/b&gt;dan tidak bisa dipisahkan&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Hampir semua program JavaScript dibangun dari kombinasi statement dan expression&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://blog-cilik.blogspot.com/feeds/5041396690965774233/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/statement-dan-expression-dalam.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/5041396690965774233'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/5041396690965774233'/><link rel='alternate' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/statement-dan-expression-dalam.html' title='Statement dan Expression dalam JavaScript'/><author><name>blogcilik</name><uri>http://www.blogger.com/profile/15754422881593101752</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-9024993991083531887.post-6109137833585006207</id><published>2026-01-02T23:21:00.000+07:00</published><updated>2026-01-03T08:49:18.501+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript Dasar"/><title type='text'>Struktur Dasar Program JavaScript (Wajib Dipahami Pemula)</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Saat mulai belajar JavaScript, banyak pemula langsung menulis kode tanpa memahami &lt;b&gt;struktur dasar program JavaScript.&lt;/b&gt; Akibatnya, kode sering error, sulit dibaca, dan membingungkan saat dikembangkan.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Di artikel ini, kita akan membahas &lt;b&gt;susunan dasar kode JavaScript&lt;/b&gt;, mulai dari penulisan statement, komentar, hingga blok kode yang benar. Artikel ini sangat penting sebagai pondasi sebelum masuk ke variabel, function, dan logika program.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;Apa Itu Struktur Dasar Program JavaScript?&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Struktur dasar program JavaScript adalah aturan &lt;b&gt;dan susunan penulisan kode&lt;/b&gt; agar JavaScript bisa dijalankan dengan benar oleh browser atau JavaScript engine.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Struktur ini meliputi:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Statement (perintah)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Comment (komentar)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Block kode&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Penulisan titik koma&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Urutan eksekusi kode&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;1. Statement (Pernyataan JavaScript)&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Statement adalah &lt;b&gt;instruksi yang dijalankan oleh JavaScript&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh statement sederhana:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a;&quot;&gt;&lt;span style=&quot;font-family: courier; font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;console.log(&quot;Hello JavaScript&quot;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;📌 Penjelasan:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;color: #999999;&quot;&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;console.log()&lt;/span&gt; &lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;→ perintah untuk menampilkan teks&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: #999999; font-family: courier;&quot;&gt;&quot;Hello JavaScript&quot;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt; → data yang ditampilkan&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Satu baris kode = satu statement.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;2. Titik Koma (Semicolon)&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript menggunakan &lt;b&gt;titik koma (;)&lt;/b&gt; untuk mengakhiri statement.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: courier;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let nama = &quot;Andi&quot;;
let umur = 20;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;💡 Catatan:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript &lt;b&gt;bisa berjalan tanpa titik koma&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tapi &lt;b&gt;sangat disarankan tetap menggunakannya&lt;/b&gt; agar kode lebih rapi dan aman dari error&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;3. Komentar (Comments)&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Komentar adalah bagian kode yang &lt;b&gt;tidak dijalankan oleh JavaScript&lt;/b&gt;. Biasanya digunakan untuk:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Penjelasan kode&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Catatan&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menonaktifkan kode sementara&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;a. Komentar Satu Baris&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: courier;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;// Ini adalah komentar satu baris
console.log(&quot;Belajar JavaScript&quot;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;b&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;

b. Komentar Multi Baris

&lt;/span&gt;&lt;/b&gt;&lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: courier;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;/*
Ini adalah komentar
lebih dari satu baris
*/&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;📌 Tips SEO &amp;amp; Coding:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Biasakan menulis komentar agar kode mudah dipahami saat dibaca ulang.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;4. Blok Kode (Code Block)&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Blok kode adalah &lt;/span&gt;&lt;b style=&quot;font-family: helvetica;&quot;&gt;sekumpulan statement &lt;/b&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;yang dibungkus dengan &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;&lt;span style=&quot;color: #999999;&quot;&gt;{ }&lt;/span&gt;.&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: courier;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;if (true) {
  console.log(&quot;Kode ini dijalankan&quot;);
}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Blok kode biasanya digunakan pada:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;color: #999999; font-family: courier;&quot;&gt;&lt;b&gt;if&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: #999999; font-family: courier;&quot;&gt;&lt;b&gt;for&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: #999999; font-family: courier;&quot;&gt;&lt;b&gt;while&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: #999999; font-family: courier;&quot;&gt;&lt;b&gt;function&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;5. Penulisan Case-Sensitive&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript bersifat &lt;b&gt;case-sensitive&lt;/b&gt;, artinya:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: courier;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;nama
Nama
NAMA&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;👉 Ketiganya dianggap &lt;b&gt;berbeda&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh error umum:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: courier;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;let nama = &quot;Budi&quot;;
console.log(Nama); // Error&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;📌 Kesimpulan:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Huruf besar dan kecil &lt;b&gt;sangat berpengaruh&lt;/b&gt; di JavaScript.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;6. Urutan Eksekusi Program&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript dijalankan &lt;b&gt;dari atas ke bawah&lt;/b&gt;, baris demi baris.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: courier;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;console.log(&quot;Baris pertama&quot;);
console.log(&quot;Baris kedua&quot;);
console.log(&quot;Baris ketiga&quot;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;
Hasil:
&lt;/span&gt;&lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: courier;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;Baris pertama
Baris kedua
Baris ketiga&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;⚠️ Jika ada error di tengah kode, baris setelahnya &lt;b&gt;tidak akan dijalankan&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;7. Struktur Dasar Program JavaScript Lengkap&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Berikut contoh struktur dasar program JavaScript yang rapi dan benar:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: courier;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;// Komentar: Program JavaScript sederhana

let nama = &quot;Andi&quot;;
let umur = 20;

if (umur &amp;gt;= 18) {
  console.log(nama + &quot; sudah dewasa&quot;);
} else {
  console.log(nama + &quot; belum dewasa&quot;);
}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Kesalahan Umum Pemula&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;❌ Lupa tanda petik&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;❌ Salah huruf besar/kecil&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;❌ Kurung kurawal tidak ditutup&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;❌ Salah urutan penulisan&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Semua kesalahan ini bisa dihindari dengan memahami struktur dasar.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Kesimpulan&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Struktur dasar program JavaScript adalah &lt;b&gt;pondasi utama&lt;/b&gt; sebelum masuk ke materi yang lebih kompleks. Dengan memahami:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Statement&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Komentar&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Blok kode&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Urutan eksekusi&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;kamu akan lebih mudah belajar JavaScript ke level berikutnya.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://blog-cilik.blogspot.com/feeds/6109137833585006207/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/struktur-dasar-program-javascript-wajib.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/6109137833585006207'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/6109137833585006207'/><link rel='alternate' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/struktur-dasar-program-javascript-wajib.html' title='Struktur Dasar Program JavaScript (Wajib Dipahami Pemula)'/><author><name>blogcilik</name><uri>http://www.blogger.com/profile/15754422881593101752</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-9024993991083531887.post-356772384236862694</id><published>2026-01-02T20:02:00.002+07:00</published><updated>2026-01-02T20:02:59.079+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript Dasar"/><title type='text'>Menjalankan JavaScript di VS Code </title><content type='html'>&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Panduan Lengkap untuk Pemula&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Setelah memahami dasar JavaScript dan cara menjalankannya di browser, langkah selanjutnya yang wajib dipelajari adalah&lt;b&gt; menjalankan JavaScript menggunakan VS Code&lt;/b&gt;. VS Code (Visual Studio Code) adalah code editor gratis, ringan, dan sangat populer di kalangan web developer.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dengan VS Code, kamu bisa:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menulis kode JavaScript dengan rapi&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menjalankan JavaScript tanpa browser&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Belajar JavaScript layaknya developer profesional&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Artikel ini akan membahas langkah demi &lt;b&gt;langkah menjalankan JavaScript di VS Code&lt;/b&gt;, khusus untuk pemula.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;Apa Itu VS Code?&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Visual Studio Code (VS Code)&lt;/b&gt; adalah text editor buatan Microsoft yang mendukung banyak bahasa pemrograman, termasuk JavaScript.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Keunggulan VS Code:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Gratis dan open source&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Ringan dan cepat&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mendukung ekstensi&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Cocok untuk pemula hingga profesional&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;Persiapan Menjalankan JavaScript di VS Code&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Sebelum mulai, pastikan kamu sudah memiliki:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;VS Code&lt;/b&gt; terinstall&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Browser&lt;/b&gt; (Chrome / Edge / Firefox)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;(Opsional)&lt;b&gt; Node.js&lt;/b&gt; untuk menjalankan JavaScript tanpa browser&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;💡 Jika kamu masih pemula, jangan khawatir. Kita mulai dari cara paling mudah.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;Cara Menjalankan JavaScript di VS Code Menggunakan Browser&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Ini adalah &lt;b&gt;cara paling sederhana dan cocok untuk pemula&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;1. Buat Folder Proyek&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Buat folder baru, misalnya:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;belajar-javascript&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Lalu buka folder tersebut di VS Code:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Klik &lt;b&gt;File → Open Folder&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Pilih folder &lt;span style=&quot;color: #999999;&quot;&gt;belajar-javascript&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;2. Buat File HTML&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Buat file baru dengan nama:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;index.html&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;
Isi dengan kode berikut:
&lt;/span&gt;&lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;Html&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang=&quot;id&quot;&amp;gt;
&amp;lt;head&amp;gt;
  &amp;lt;meta charset=&quot;UTF-8&quot;&amp;gt;
  &amp;lt;title&amp;gt;Belajar JavaScript&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;

  &amp;lt;h1&amp;gt;Belajar JavaScript di VS Code&amp;lt;/h1&amp;gt;

  &amp;lt;script&amp;gt;
    console.log(&quot;Hello JavaScript!&quot;);
  &amp;lt;/script&amp;gt;

&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;3. Jalankan di Browser&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Klik kanan pada &lt;span style=&quot;color: #999999;&quot;&gt;index.html&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Pilih&lt;b&gt; Open with Browser&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tekan &lt;b&gt;F12 → Console&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Jika berhasil, akan muncul:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;Hello JavaScript!&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;🎉 Selamat! JavaScript kamu sudah berjalan.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Menjalankan JavaScript dengan File &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;.js&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt; Terpisah&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Agar kode lebih rapi, sebaiknya JavaScript dipisahkan dari HTML.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;1. Buat File JavaScript&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Buat file baru:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;script.js&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;

Isi dengan:

&lt;/span&gt;&lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;alert(&quot;JavaScript berjalan dari file terpisah!&quot;);
console.log(&quot;Belajar JavaScript di VS Code&quot;);&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;2. Hubungkan ke HTML&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Ubah index.html menjadi:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;Html&lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;&amp;lt;script src=&quot;script.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Sekarang JavaScript dijalankan dari file terpisah.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;Menjalankan JavaScript di VS Code Tanpa Browser (Node.js)&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Cara ini biasanya digunakan saat:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Belajar logika JavaScript&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Membuat aplikasi backend&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Testing kode JavaScript&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;1. Install Node.js&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Download dan install Node.js dari situs resminya.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Setelah itu cek di terminal:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;Bash&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;node -v&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Jika versi muncul, berarti Node.js sudah terpasang.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;2. Buat File JavaScript&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;app.js&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;

Isi:

&lt;/span&gt;&lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;console.log(&quot;Halo, ini JavaScript dari Node.js&quot;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;3. Jalankan di Terminal VS Code&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Buka terminal di VS Code:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Klik &lt;b&gt;Terminal → New Terminal&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Jalankan perintah:&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;Bash&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;node app.js&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;

Output:

&lt;/span&gt;&lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;Halo, ini JavaScript dari Node.js&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;Ekstensi VS Code yang Direkomendasikan&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Agar belajar JavaScript lebih nyaman:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;1. Live Server&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menjalankan HTML secara otomatis di browser&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;2.JavaScript (ES6) Code Snippets&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mempercepat penulisan kode&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;3. Prettier&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Merapikan kode otomatis&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Kesalahan Umum Pemula&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Beberapa kesalahan yang sering terjadi:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Lupa menyimpan file sebelum dijalankan&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Salah penamaan file .js&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Script tidak terhubung ke HTML&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Node.js belum terinstall&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tenang, ini hal yang &lt;b&gt;sangat wajar&lt;/b&gt; saat belajar.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Kesimpulan&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menjalankan JavaScript di VS Code adalah langkah penting untuk menjadi developer JavaScript. Kamu bisa:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menjalankan JavaScript lewat browser&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menggunakan file &lt;b&gt;&lt;span style=&quot;color: #999999;&quot;&gt;.js&lt;/span&gt;&lt;/b&gt; terpisah&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menjalankan JavaScript tanpa browser menggunakan &lt;span style=&quot;color: #999999;&quot;&gt;Node.js&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Setelah memahami ini, kamu siap masuk ke materi JavaScript yang lebih dalam 🚀&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://blog-cilik.blogspot.com/feeds/356772384236862694/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/menjalankan-javascript-di-vs-code.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/356772384236862694'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/356772384236862694'/><link rel='alternate' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/menjalankan-javascript-di-vs-code.html' title='Menjalankan JavaScript di VS Code '/><author><name>blogcilik</name><uri>http://www.blogger.com/profile/15754422881593101752</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-9024993991083531887.post-273437561587020462</id><published>2026-01-02T15:24:00.003+07:00</published><updated>2026-01-03T09:59:35.480+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript Dasar"/><title type='text'>Cara Menjalankan JavaScript di Browser (Panduan Lengkap untuk Pemula)</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript adalah bahasa pemrograman &lt;b&gt;yang langsung dijalankan oleh browser&lt;/b&gt;. Artinya, kamu tidak perlu menginstal software rumit untuk mulai belajar JavaScript. Cukup browser seperti &lt;b&gt;Google Chrome, Firefox, atau Edge&lt;/b&gt;, kamu sudah bisa menulis dan menjalankan JavaScript.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Pada artikel ini, kita akan membahas berbagai &lt;b&gt;cara menjalankan JavaScript di browser&lt;/b&gt;, mulai dari yang paling dasar hingga yang sering digunakan dalam pengembangan website.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;1. Menjalankan JavaScript Menggunakan&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt; &lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #999999;&quot;&gt;&lt;b&gt;&amp;lt;script&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;b style=&quot;font-size: x-large;&quot;&gt; &lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;di HTML&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Cara paling umum dan paling dasar adalah menggunakan tag &lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;&amp;lt;script&amp;gt;&lt;/b&gt;&lt;/span&gt; di dalam file HTML.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;Html&lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
  &amp;lt;title&amp;gt;Belajar JavaScript&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;

&amp;lt;h1&amp;gt;Hello JavaScript&amp;lt;/h1&amp;gt;

&amp;lt;script&amp;gt;
  alert(&quot;JavaScript berhasil dijalankan!&quot;);
&amp;lt;/script&amp;gt;

&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Penjelasan:&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kode JavaScript ditulis di dalam tag &lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;&amp;lt;script&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Browser akan langsung mengeksekusi JavaScript saat halaman dimuat&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;✅ Cocok untuk pemula&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;❌ Kurang rapi jika kode JavaScript sudah banyak&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b style=&quot;font-size: x-large;&quot;&gt;2. Menjalankan JavaScript Menggunakan File &lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;.js &lt;/span&gt;&lt;/b&gt;&lt;b style=&quot;font-size: x-large;&quot;&gt;(External JavaScript)&lt;/b&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Ini adalah cara terbaik dan paling direkomendasikan.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh file &lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;script.js&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;alert(&quot;Halo dari file JavaScript!&quot;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;b&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;
Hubungkan ke HTML:
&lt;/span&gt;&lt;/b&gt;&lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;Html&lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;&amp;lt;script src=&quot;script.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Keuntungan:&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kode lebih rapi dan terstruktur&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mudah dikelola&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Digunakan di hampir semua website profesional&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;3. Menjalankan JavaScript di Browser Console (Developer Tools)&lt;/b&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Browser memiliki &lt;b&gt;Console&lt;/b&gt; untuk menjalankan JavaScript secara langsung.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Cara membuka Console:&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Windows / Linux&lt;/b&gt;: Ctrl + Shift + I&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Mac&lt;/b&gt;: Cmd + Option + I&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Pilih tab &lt;b&gt;Console&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;console.log(&quot;Hello JavaScript&quot;);&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tekan &lt;b&gt;Enter&lt;/b&gt;, dan hasilnya langsung muncul.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;✅ Sangat cocok untuk belajar dan testing&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;✅ Digunakan oleh developer profesional&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;4. Menjalankan JavaScript Menggunakan Attribute HTML&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript juga bisa dijalankan melalui event HTML, seperti&lt;span style=&quot;color: red;&quot;&gt; &lt;b&gt;onclick.&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;contoh:&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;Html&lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;&amp;lt;button onclick=&quot;alert(&#39;Tombol diklik!&#39;)&quot;&amp;gt;
  Klik Saya
&amp;lt;/button&amp;gt;&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Penjelasan:&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript dijalankan saat event terjadi&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Biasanya digunakan untuk interaksi sederhana&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;❌ Tidak direkomendasikan untuk proyek besar&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;5. Menjalankan JavaScript Saat Halaman Selesai Dimuat&lt;/b&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Agar JavaScript dijalankan setelah halaman siap, gunakan &lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;DOMContentLoaded.&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;Html&lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;&amp;lt;script&amp;gt;
document.addEventListener(&quot;DOMContentLoaded&quot;, function() {
  console.log(&quot;Halaman sudah siap&quot;);
});
&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;📌 Penting agar JavaScript tidak error karena elemen HTML belum tersedia.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b style=&quot;font-size: x-large;&quot;&gt;6. Menggunakan &lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: #999999;&quot;&gt;defer&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;dan &lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #999999;&quot;&gt;&lt;b&gt;async&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;color: #444444; font-family: helvetica;&quot;&gt;&lt;b&gt;defer&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;Html&lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;&amp;lt;script src=&quot;script.js&quot; defer&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript dijalankan setelah HTML selesai diproses&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Sangat direkomendasikan&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;async&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;Html&lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;&amp;lt;script src=&quot;script.js&quot; async&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript dijalankan secara asynchronous&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Cocok untuk script pihak ketiga (iklan, analytics)&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;7. Mengecek Hasil JavaScript dengan &lt;/span&gt;&lt;span style=&quot;color: #999999;&quot;&gt;console.log()&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Daripada&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt; &lt;span&gt;alert&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;, developer biasanya menggunakan:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;line-height: 1.6; padding: 10px 12px 12px; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: #0f172a; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12.5px; white-space-collapse: preserve;&quot;&gt;console.log(&quot;Ini pesan debug&quot;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Hasilnya bisa dilihat di &lt;b&gt;Console Browser.&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;Kesimpulan&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Berikut ringkasan cara menjalankan JavaScript di browser:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Cara&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;script&amp;gt; di HTML&lt;/span&gt;&lt;/b&gt; c&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;ocok untuk&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Belajar dasar&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Cara &lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;File .js&lt;/span&gt;&lt;/b&gt; cocok untuk&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Website profesional&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Cara &lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;Console Browser&lt;/span&gt;&lt;/b&gt; untuk&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Testing &amp;amp; belajar&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Cara &lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;Event HTML&lt;/span&gt;&lt;/b&gt; cocok untuk&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Interaksi sederhana&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Cara &lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;defer&lt;/span&gt; &lt;/b&gt;cocok untuk&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Praktik terbaik&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;👉 Untuk pemula, disarankan:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;1. Mulai dari &lt;b&gt;&amp;lt;script&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;2. Lanjut ke &lt;b&gt;file .js&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;3. Biasakan menggunakan &lt;b&gt;Console&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://blog-cilik.blogspot.com/feeds/273437561587020462/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/cara-menjalankan-javascript-di-browser.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/273437561587020462'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/273437561587020462'/><link rel='alternate' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/cara-menjalankan-javascript-di-browser.html' title='Cara Menjalankan JavaScript di Browser (Panduan Lengkap untuk Pemula)'/><author><name>blogcilik</name><uri>http://www.blogger.com/profile/15754422881593101752</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-9024993991083531887.post-7170204561229802041</id><published>2026-01-01T22:44:00.002+07:00</published><updated>2026-01-01T22:44:28.865+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript Dasar"/><title type='text'>JavaScript Client Side vs Server Side: Bedanya Di Mana Sih?</title><content type='html'>&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kalau kamu pakai JavaScript buat bikin tombol, validasi form, atau efek interaktif di halaman, kemungkinan besar kamu lagi main di client side.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tapi kalau JavaScript kamu pakai buat proses data, login, atau API, itu sudah masuk ke server side.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Namanya sama-sama JavaScript, tapi tempat kerjanya beda.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;Apa Maksud Client Side dan Server Side?&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Biar gampang dibayangin:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Client side&lt;/b&gt; → jalan di browser pengguna&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Server side&lt;/b&gt; → jalan di server&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Sederhananya:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Client side&lt;/b&gt; = apa yang dilihat dan dirasakan user&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Server side&lt;/b&gt; = proses di belakang layar&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;JavaScript Client Side:&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Yang Terjadi di Browser&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Client side JavaScript dijalankan langsung di browser, seperti:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Chrome&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Firefox&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Edge&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Safari&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Biasanya dipakai untuk:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Klik tombol&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Validasi form&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mengubah tampilan halaman&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Animasi sederhana&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Contoh yang sering banget ditemui:&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;document.querySelector(&quot;button&quot;).addEventListener(&quot;click&quot;, () =&amp;gt; {
  alert(&quot;Tombol diklik!&quot;);
});&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kode ini langsung jalan di browser, tanpa server ikut campur.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;Kelebihan Client Side JavaScript&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kenapa client side sering dipakai?&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Karena:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Responnya cepat&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tidak perlu bolak-balik ke server&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Interaksi terasa lebih halus&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Makanya hampir semua website modern pasti pakai JavaScript di sisi ini.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;Keterbatasan Client Side&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tapi client side juga punya batasan.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Beberapa hal yang tidak aman dilakukan di client side:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menyimpan password&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Proses login utama&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mengelola database&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Karena kodenya bisa:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dilihat user&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Diubah lewat browser&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dimanipulasi&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;JavaScript Server Side: Kerja di Balik Layar&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Server side JavaScript dijalankan di server, biasanya pakai Node.js.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Di sini JavaScript dipakai untuk:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mengolah data&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menyimpan ke database&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mengatur login&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Membuat API&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;User tidak melihat langsung kodenya, hanya hasilnya.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Contoh Kasus Server Side&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Misalnya:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;User login&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Data dikirim ke server&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Server cek ke database&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Server kirim respon&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Semua proses itu terjadi di server, bukan di browser.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;Kenapa JavaScript Bisa Jalan di Server?&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dulu JavaScript cuma ada di browser.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tapi sejak muncul Node.js, JavaScript bisa dijalankan di luar browser.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Inilah yang bikin JavaScript:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Bisa dipakai frontend&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Bisa dipakai backend&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Satu bahasa, banyak peran&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;Perbandingan Singkat Client vs Server&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kalau diringkas:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Client Side JavaScript&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Jalan di browser&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Fokus tampilan &amp;amp; interaksi&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Cepat &amp;amp; responsif&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kurang aman untuk data sensitif&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Server Side JavaScript&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Jalan di server&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Fokus logika &amp;amp; data&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Lebih aman&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tidak langsung terlihat user&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Jadi, Harus Pilih yang Mana?&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Jawabannya: dua-duanya 😄&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Di aplikasi web modern:&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Client side menangani interaksi&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Server side menangani logika dan data&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Keduanya saling melengkapi, bukan saling menggantikan.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Kalau Dilihat dari Kacamata Pemula&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Di tahap awal belajar JavaScript:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Fokus dulu ke client side&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Pahami DOM dan event&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Biasakan logika dasar&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Server side bisa menyusul setelah konsep dasarnya kuat.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;Penutup&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Walaupun namanya sama-sama JavaScript,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;client side dan server side punya tugas yang berbeda.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dengan memahami perbedaannya, kamu jadi:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tidak salah taruh logika&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tidak bingung saat belajar framework&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Lebih paham alur aplikasi web&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Di artikel berikutnya, kita bakal bahas struktur dasar JavaScript sebagai bekal mulai ngoding lebih serius.&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://blog-cilik.blogspot.com/feeds/7170204561229802041/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/javascript-client-side-vs-server-side.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/7170204561229802041'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/7170204561229802041'/><link rel='alternate' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/javascript-client-side-vs-server-side.html' title='JavaScript Client Side vs Server Side: Bedanya Di Mana Sih?'/><author><name>blogcilik</name><uri>http://www.blogger.com/profile/15754422881593101752</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-9024993991083531887.post-3199339919314987375</id><published>2026-01-01T18:35:00.004+07:00</published><updated>2026-01-20T20:50:50.142+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript Dasar"/><title type='text'>Cara Kerja JavaScript di Browser: Apa yang Sebenarnya Terjadi?</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kalau hari ini kamu buka website lalu klik tombol, muncul alert, atau form bisa validasi tanpa reload halaman, itu semua kelihatannya sederhana.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tapi di balik layar browser, ada proses yang cukup panjang sebelum JavaScript bisa jalan.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menariknya, semua itu terjadi &lt;b&gt;dalam hitungan milidetik&lt;/b&gt;, tanpa kita sadari.&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;Saat Website Dibuka di Browser&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Ketika kamu mengetik alamat website lalu tekan Enter, browser tidak langsung menampilkan halaman begitu saja.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Yang terjadi kurang lebih seperti ini:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Browser meminta file HTML ke server&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;HTML mulai dibaca dari atas ke bawah&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Browser membangun struktur halaman&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Di tahap ini, JavaScript &lt;b&gt;belum tentu langsung dijalankan&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;HTML Dibaca, JavaScript Menyusul&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Browser membaca HTML secara berurutan.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Saat bertemu tag &lt;span style=&quot;color: #cccccc;&quot;&gt;&amp;lt;script&amp;gt;&lt;/span&gt;, browser akan berhenti sejenak.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kenapa? Karena JavaScript &lt;b&gt;bisa memengaruhi isi halaman&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kalau JavaScript langsung dijalankan tanpa menunggu, hasil tampilannya bisa berantakan.&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;Peran Mesin JavaScript di Browser&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Setiap browser punya mesin JavaScript sendiri:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Chrome pakai &lt;b&gt;V8&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Firefox pakai &lt;b&gt;SpiderMonkey&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Safari pakai &lt;b&gt;JavaScriptCore&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mesin inilah yang:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Membaca kode JavaScript&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mengubahnya jadi perintah mesin&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menjalankannya di browser&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Semua proses ini terjadi di sisi pengguna, bukan di server.&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;JavaScript dan DOM: Pasangan Tidak Terpisahkan&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Begitu halaman terbentuk, browser membuat &lt;/span&gt;&lt;b style=&quot;font-family: helvetica;&quot;&gt;DOM (Document Object Model)&lt;/b&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;DOM ini bisa dibilang “peta” dari seluruh elemen HTML.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript berinteraksi dengan halaman lewat DOM:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mengubah teks&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menambah elemen&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menghapus elemen&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Merespon klik pengguna&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Inilah alasan JavaScript disebut bikin website jadi &lt;b&gt;interaktif&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;Kenapa Posisi Script Itu Penting?&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mungkin kamu pernah lihat JavaScript ditaruh di:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;Html&lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;&amp;lt;script src=&quot;script.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kalau script ditaruh di atas, JavaScript bisa dijalankan &lt;b&gt;sebelum HTML selesai dibaca&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Akibatnya, elemen yang ingin diakses belum ada.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Makanya, banyak developer menaruh JavaScript di bagian bawah atau pakai event tertentu.&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;Event: JavaScript Menunggu Aksi&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript tidak selalu jalan sendiri.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Sering kali, JavaScript &lt;b&gt;menunggu sesuatu terjadi.&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contohnya:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Klik tombol&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Ketik di input&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Scroll halaman&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Baru setelah itu, kode JavaScript dijalankan.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dari sinilah muncul istilah &lt;b&gt;event-driven&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;Sinkron dan Asinkron (Sedikit, Tapi Penting)&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tidak semua JavaScript berjalan berurutan.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Ada proses yang:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Harus ditunggu&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Berjalan di belakang layar&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Misalnya:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Ambil data dari server&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Delay waktu&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tunggu respon API&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Browser punya mekanisme sendiri untuk mengatur ini supaya halaman tidak freeze.&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;Kalau Dilihat dari Kacamata Pemula&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Di awal belajar, mungkin semua ini terdengar ribet.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tapi sebenarnya, kamu tidak perlu menghafal semuanya sekaligus.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Yang penting dipahami dulu:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript dijalankan oleh browser&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Browser membaca HTML dulu&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript berinteraksi lewat DOM&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Event menentukan kapan kode dijalankan&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica; font-size: large;&quot;&gt;&lt;b&gt;Penutup&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Setiap kali JavaScript jalan di browser, ada banyak proses yang bekerja di balik layar.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kita mungkin tidak melihatnya, tapi efeknya langsung terasa.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kalau kamu sudah paham cara kerjanya, banyak error yang awalnya membingungkan akan terasa lebih masuk akal.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Di artikel selanjutnya, kita akan mulai masuk ke &lt;a href=&quot;https://blog-cilik.blogspot.com/2026/01/struktur-dasar-javascript-kesalahan.html&quot; target=&quot;_blank&quot;&gt;struktur dasar JavaScript &lt;/a&gt;supaya kamu bisa mulai nulis kode dengan lebih percaya diri.&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://blog-cilik.blogspot.com/feeds/3199339919314987375/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/cara-kerja-javascript-di-browser-apa.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/3199339919314987375'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/3199339919314987375'/><link rel='alternate' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/cara-kerja-javascript-di-browser-apa.html' title='Cara Kerja JavaScript di Browser: Apa yang Sebenarnya Terjadi?'/><author><name>blogcilik</name><uri>http://www.blogger.com/profile/15754422881593101752</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-9024993991083531887.post-1239173176672059771</id><published>2026-01-01T14:39:00.003+07:00</published><updated>2026-01-19T20:41:49.787+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript Dasar"/><title type='text'>Sejarah Perkembangan JavaScript: Dari Script Sederhana hingga Bahasa Utama Web</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kalau kamu ngoding JavaScript hari ini—entah buat tombol, validasi form, sampai bikin aplikasi web—percaya atau tidak, JavaScript &lt;b&gt;awalnya dibuat cuma dalam hitungan hari&lt;/b&gt;&amp;nbsp;😄&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tapi sekarang? JavaScript sudah jadi bahasa wajib &lt;b&gt;web developer&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Yuk kita bahas sejarahnya dari awal, versi santai ala ngoding harian.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica; font-size: medium;&quot;&gt;&lt;b&gt;Awal Mula JavaScript (1995)&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;div&gt;Tahun 1995, web masih sangat sederhana.&lt;/div&gt;&lt;div&gt;Website cuma berisi teks dan gambar, tanpa interaksi.&lt;/div&gt;&lt;div&gt;Di perusahaan Netscape, ada seorang programmer bernama Brendan Eich yang diberi tugas:&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;“Bikin bahasa pemrograman sederhana buat browser.”&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Targetnya:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mudah dipelajari&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Bisa jalan langsung di browser&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Bisa bikin halaman web jadi interaktif&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;⏱️ Fakta unik&lt;/b&gt;:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript versi pertama dibuat &lt;b&gt;hanya dalam ±10 hari&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica; font-size: medium;&quot;&gt;&lt;b&gt;Nama Awalnya Bukan JavaScript&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript sempat gonta-ganti nama:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ol&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;Mocha&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;LiveScript&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;JavaScript &lt;/b&gt;(karena strategi marketing)&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kenapa JavaScript? Karena saat itu &lt;b&gt;bahasa Java sedang populer&lt;/b&gt;, jadi namanya “dipinjam” biar kelihatan keren 😅&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;⚠️ Catatan penting:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript ≠ Java&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dua bahasa ini &lt;b&gt;berbeda total&lt;/b&gt;, cuma namanya mirip.&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica; font-size: medium;&quot;&gt;&lt;b&gt;JavaScript Masuk Browser (Netscape &amp;amp; Internet Explorer)&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Awalnya &lt;a href=&quot;https://blog-cilik.blogspot.com/2026/01/sekilas-sejarah-javascript-di-netscape.html&quot; target=&quot;_blank&quot;&gt;JavaScript cuma ada di Netscape Navigator&lt;/a&gt;&lt;b&gt;.&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Lalu Microsoft bikin versi sendiri bernama &lt;b&gt;JScript&lt;/b&gt; di Internet Explorer.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Masalah mulai muncul:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kode jalan di Netscape ❌&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tapi error di Internet Explorer ❌&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Akhirnya developer harus bikin kode khusus untuk tiap browser. Ribet banget.&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica; font-size: medium;&quot;&gt;&lt;b&gt;Standarisasi: Lahirnya ECMAScript&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Agar JavaScript tidak berantakan, dibuatlah standar bernama &lt;a href=&quot;https://blog-cilik.blogspot.com/2026/01/sejarah-ecmascript-standar-yang-membuat.html&quot; target=&quot;_blank&quot;&gt;ECMAScript&lt;/a&gt; oleh ECMA International.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Versi-versi penting:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;ES1 (1997)&lt;/b&gt; → standar pertama&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;ES3 (1999)&lt;/b&gt; → mulai stabil&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;ES5 (2009)&lt;/b&gt; → dipakai luas bertahun-tahun&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;ES6 / ES2015 &lt;/b&gt;→ revolusi besar 🚀&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;&lt;b&gt;&lt;span style=&quot;color: #666666; font-family: helvetica; font-size: medium;&quot;&gt;Revolusi JavaScript: ES6 (2015)&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Ini titik balik JavaScript modern.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Fitur-fitur penting yang sering kamu pakai sekarang:&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;// let &amp;amp; const
let nama = &quot;JavaScript&quot;;
const tahun = 1995;

// arrow function
const halo = () =&amp;gt; {
  console.log(&quot;Halo dunia!&quot;);
};

// template literal
console.log(`Belajar ${nama}`);&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Sejak ES6:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kode lebih rapi&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Lebih mudah dibaca&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Lebih mirip bahasa pemrograman modern&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica; font-size: medium;&quot;&gt;&lt;b&gt;JavaScript Tidak Hanya di Browser&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dulu JavaScript cuma buat:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Alert&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Validasi form&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Manipulasi HTML&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Sekarang??&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dengan JavaScript kamu bisa:&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Backend (Node.js)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mobile App (React Native)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Desktop App (Electron)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Game&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;IoT&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh backend sederhana:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;console.log(&quot;Server jalan pakai JavaScript&quot;);&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Satu bahasa, banyak platform. 🔥&lt;/div&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;JavaScript di Era Sekarang&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Saat ini JavaScript adalah:&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ol&gt;&lt;li&gt;Bahasa paling banyak digunakan di dunia&lt;/li&gt;&lt;li&gt;Wajib untuk Frontend Developer&lt;/li&gt;&lt;li&gt;Dasar untuk framework populer:&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul&gt;&lt;li&gt;React&lt;/li&gt;&lt;li&gt;Vue&lt;/li&gt;&lt;li&gt;Angular&lt;/li&gt;&lt;li&gt;Next.js&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Dan hampir &lt;b&gt;semua website modern&lt;/b&gt; memakai JavaScript.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;color: #666666; font-size: medium;&quot;&gt;&lt;b&gt;Kenapa Penting Tahu Sejarah JavaScript?&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Sebagai coder harian, tahu sejarah itu penting karena:&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Paham kenapa sintaks JavaScript “aneh”&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Mengerti perbedaan JavaScript lama vs modern&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Tidak kaget lihat kode jadul (&lt;i&gt;&lt;span style=&quot;color: #ffa400;&quot;&gt;var,&lt;/span&gt; &lt;span style=&quot;color: #ffa400;&quot;&gt;callback hell&lt;/span&gt;&lt;/i&gt;, dll)&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #666666; font-size: medium;&quot;&gt;Kesimpulan&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;JavaScript:
Lahir tahun 1995
Awalnya bahasa kecil untuk browser
Berkembang jadi bahasa utama web &amp;amp; aplikasi
Terus update setiap tahun
Kalau kamu belajar JavaScript sekarang, kamu belajar &lt;b&gt;bahasa masa depan web&lt;/b&gt; 🚀
📌&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Artikel selanjutnya di JavaScript Dasar:&amp;nbsp;&lt;/div&gt;&lt;/span&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; font-family: system-ui, -apple-system, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Arial, &amp;quot;Noto Sans&amp;quot;, &amp;quot;Liberation Sans&amp;quot;, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;; font-feature-settings: normal; font-kerning: auto; font-language-override: normal; font-optical-sizing: auto; font-size-adjust: none; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; line-height: normal; margin-bottom: 1.5rem; margin-top: 0px; text-align: left;&quot;&gt;&lt;a href=&quot;https://blog-cilik.blogspot.com/2026/01/struktur-dasar-program-javascript-wajib.html&quot; target=&quot;_blank&quot;&gt;Struktur Dasar Program JavaScript (Wajib Dipahami Pemula)&lt;/a&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='https://blog-cilik.blogspot.com/feeds/1239173176672059771/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/sejarah-perkembangan-javascript-dari.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/1239173176672059771'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/1239173176672059771'/><link rel='alternate' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/sejarah-perkembangan-javascript-dari.html' title='Sejarah Perkembangan JavaScript: Dari Script Sederhana hingga Bahasa Utama Web'/><author><name>blogcilik</name><uri>http://www.blogger.com/profile/15754422881593101752</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-9024993991083531887.post-447186355459355797</id><published>2026-01-01T09:36:00.009+07:00</published><updated>2026-01-19T10:38:14.005+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript Dasar"/><title type='text'>Apa Itu JavaScript? Pengertian &amp; Fungsi Lengkap untuk Pemula</title><content type='html'>&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kalau kamu baru mulai belajar dunia &lt;a href=&quot;https://blog-cilik.blogspot.com/2026/01/web-programming-javascript.html.html&quot; target=&quot;_blank&quot;&gt;web programming&lt;/a&gt;, pasti sering mendengar kata &lt;b&gt;JavaScript&lt;/b&gt;. Hampir semua website modern saat ini menggunakan JavaScript, mulai dari blog sederhana sampai aplikasi besar seperti YouTube, Facebook, dan Instagram.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Lalu sebenarnya &lt;b&gt;apa itu JavaScript?&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Apa fungsinya, dan kenapa JavaScript sangat penting untuk dipelajari?&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Di artikel ini, kita akan membahas &lt;b&gt;pengertian JavaScript, fungsi JavaScript, serta contoh penggunaannya&lt;/b&gt;, khusus untuk pemula dengan bahasa yang mudah dipahami.&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica; font-size: medium;&quot;&gt;&lt;b&gt;Pengertian JavaScript&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript adalah bahasa pemrograman yang digunakan untuk membuat halaman web menjadi interaktif dan dinamis.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Jika:&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;HTML berfungsi untuk membuat struktur halaman&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;CSS berfungsi untuk mengatur tampilan&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Maka &lt;b&gt;JavaScript&lt;/b&gt; berfungsi untuk: 👉 &lt;b&gt;Memberikan logika dan interaksi pada website&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh sederhana penggunaan JavaScript:&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menampilkan popup / alert&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Validasi form (login, daftar)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mengubah isi halaman tanpa reload&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Membuat animasi&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menangani klik tombol&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript pertama kali dikembangkan oleh &lt;b&gt;Brendan Eich&lt;/b&gt; pada tahun 1995 dan hingga sekarang menjadi &lt;b&gt;bahasa utama di web development.&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica; font-size: medium;&quot;&gt;&lt;b&gt;Kenapa JavaScript Sangat Penting?&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Berikut beberapa alasan kenapa JavaScript wajib dipelajari:&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;1. Digunakan di Hampir Semua Website&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Lebih dari 95% website di internet menggunakan JavaScript.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;2. Bisa Jalan di Browser Tanpa Install&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript langsung dijalankan di browser seperti:&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Google Chrome&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Firefox&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Edge&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Tanpa perlu install software tambahan.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;3. Bisa Digunakan di Banyak Platform&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Saat ini JavaScript tidak hanya untuk web:&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Frontend (tampilan website)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Backend (server, API)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mobile App&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Desktop App&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Game&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;&lt;b style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;Fungsi JavaScript dalam Website&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Berikut fungsi utama JavaScript yang paling sering digunakan:&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;1. Membuat Website Interaktif&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript memungkinkan website merespons aksi pengguna, seperti:&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Klik tombol&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Scroll halaman&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Input teks&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh:&lt;/span&gt;&lt;/p&gt;
&lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;Html&lt;/div&gt;&lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;span style=&quot;background-color: #f8fafc; color: #0f172a; font-family: helvetica; font-size: 12.5px; text-align: justify; white-space-collapse: preserve;&quot;&gt;&amp;lt;button onclick=&quot;alert(&#39;Halo Dunia!&#39;)&quot;&amp;gt;Klik Saya&amp;lt;/button&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;b style=&quot;font-family: helvetica;&quot;&gt;2. Memvalidasi Form&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript bisa mengecek data sebelum dikirim ke server.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh:&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Email harus valid&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Password minimal 8 karakter&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Form tidak boleh kosong&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Hal ini membuat website lebih aman dan nyaman.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;3. Mengubah Konten Tanpa Reload Halaman&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dengan JavaScript, konten bisa berubah tanpa refresh halaman, seperti:&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Load data otomatis&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Infinite scroll&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Like &amp;amp; comment realtime&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Teknologi ini sering disebut &lt;b&gt;AJAX &lt;/b&gt;atau &lt;b&gt;Fetch API&lt;/b&gt;.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;4. Membuat Animasi &amp;amp; Efek Visual&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript bisa digunakan untuk:&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Animasi slider&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dropdown menu&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Popup modal&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Efek transisi&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Biasanya dikombinasikan dengan CSS agar tampilannya lebih halus.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;5. Mengontrol HTML &amp;amp; CSS (DOM Manipulation)&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript dapat:&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mengubah teks HTML&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Menambah / menghapus elemen&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mengubah warna, ukuran, dan class CSS&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh:&lt;/span&gt;&lt;/p&gt;
&lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript&lt;/div&gt;&lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;&lt;span style=&quot;background-color: #f8fafc; color: #0f172a; font-family: helvetica; font-size: 12.5px; text-align: justify; white-space-collapse: preserve;&quot;&gt;document.getElementById(&quot;judul&quot;).innerHTML = &quot;Belajar JavaScript&quot;;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
    
&lt;h2 style=&quot;text-align: justify;&quot;&gt;&lt;b style=&quot;font-family: helvetica; font-size: large;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;JavaScript Digunakan di Mana Saja?&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript sangat fleksibel dan digunakan di banyak bidang:&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;🔹 &lt;b&gt;Frontend Development&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Membuat tampilan website interaktif menggunakan:&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;a href=&quot;https://blog-cilik.blogspot.com/2026/01/aturan-dasar-membuat-tampilan-website.html&quot; target=&quot;_blank&quot;&gt;JavaScript murni&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Framework seperti React, Vue, Angular&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;🔹 &lt;b&gt;Backend Development&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dengan Node.js, JavaScript bisa digunakan di server:&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Membuat API&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mengelola database&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Autentikasi user&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;🔹&lt;b&gt; Mobile App&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript juga dipakai untuk aplikasi Android &amp;amp; iOS menggunakan:&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;React Native&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Ionic&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;🔹 &lt;b&gt;Game Development&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Banyak game berbasis browser dibuat dengan JavaScript.&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica; font-size: medium;&quot;&gt;&lt;b&gt;JavaScript untuk Pemula, Sulit atau Tidak?&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Jawabannya: tidak sulit jika bertahap.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript sangat cocok untuk pemula karena:&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Sintaks mudah dipahami&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Banyak contoh di internet&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Komunitas besar&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Dokumentasi lengkap&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Yang penting: ✅ Belajar dari dasar&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;✅ Banyak latihan&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;✅ Jangan langsung lompat ke framework&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica; font-size: medium;&quot;&gt;&lt;b&gt;Kesimpulan&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;JavaScript adalah bahasa pemrograman penting&lt;/b&gt; yang digunakan untuk membuat website menjadi interaktif dan dinamis.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Ringkasannya:&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;JavaScript ≠ Java (beda bahasa)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Digunakan di hampir semua website&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Bisa untuk frontend &amp;amp; backend&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Cocok untuk pemula&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Sangat menjanjikan untuk karier&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Jika kamu serius ingin belajar web development, JavaScript adalah langkah awal yang tepat. Selanjutnya kita akan membahas&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: helvetica; text-align: left;&quot;&gt;&lt;a href=&quot;https://blog-cilik.blogspot.com/2026/01/case-sensitive-pada-javascript.html&quot; target=&quot;_blank&quot;&gt;Case Sensitive pada JavaScript: Pengertian, Contoh, dan Kesalahan Umum&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='https://blog-cilik.blogspot.com/feeds/447186355459355797/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/apa-itu-javascript-pengertian-fungsi.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/447186355459355797'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/447186355459355797'/><link rel='alternate' type='text/html' href='https://blog-cilik.blogspot.com/2026/01/apa-itu-javascript-pengertian-fungsi.html' title='Apa Itu JavaScript? Pengertian &amp; Fungsi Lengkap untuk Pemula'/><author><name>blogcilik</name><uri>http://www.blogger.com/profile/15754422881593101752</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-9024993991083531887.post-8421416911927580752</id><published>2025-12-28T20:40:00.016+07:00</published><updated>2026-01-14T10:22:55.890+07:00</updated><title type='text'>Arrow Function JavaScript</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;catatan ngoding sederhana&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Beberapa waktu lalu, saya buka kembali kode JavaScript lama yang pernah saya tulis.
Saat itu saya sadar, banyak fungsi yang sebenarnya bisa dibuat lebih ringkas.
Bukan salah, kodenya tetap jalan.
Tapi setelah mengenal arrow function, cara saya menulis JavaScript jadi sedikit berubah.
Lebih sederhana, lebih rapi, dan lebih enak dibaca.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica; font-size: medium;&quot;&gt;&lt;b&gt;Apa Itu Arrow Function?&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Arrow function adalah cara menulis function yang lebih singkat di JavaScript modern (ES6).&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Contoh function biasa:
&lt;/span&gt;&lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript&lt;/div&gt;&lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;function halo() {
  return &quot;Halo JavaScript&quot;;
}
&lt;/div&gt;&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;
Dengan arrow function:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;
  
 &lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript&lt;/div&gt;&lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;     const halo = () =&amp;gt; &quot;Halo JavaScript&quot;;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Secara fungsi sama, tapi penulisannya lebih ringkas.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kenapa Arrow Function Banyak Dipakai?
Dari pengalaman ngoding sehari-hari, arrow function sering dipakai karena:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Kode jadi lebih pendek&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Mudah dibaca&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Cocok untuk fungsi sederhana&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Sangat pas untuk callback dan event&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Bukan berarti function biasa itu buruk, hanya saja arrow function sering lebih praktis.&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica; font-size: medium;&quot;&gt;&lt;b&gt;Bentuk Dasar Arrow Function&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;b style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Tanpa Parameter&lt;/b&gt;&lt;/h3&gt;

 &lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript&lt;/div&gt;&lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;const pesan = () =&amp;gt; {
  console.log(&quot;Belajar JavaScript pelan-pelan&quot;);
     };&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;Satu Parameter&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Jika hanya satu parameter, tanda kurung boleh dihilangkan.&lt;/span&gt;&lt;/div&gt;

&lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript&lt;/div&gt;&lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;const sapa = nama =&amp;gt; {
  return `Halo ${nama}`;
};&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #999999; font-family: helvetica;&quot;&gt;&lt;b&gt;Atau versi lebih ringkas:

&lt;/b&gt;&lt;/span&gt;&lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript&lt;/div&gt;&lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;const sapa = nama =&amp;gt; `Halo ${nama}`;&lt;/div&gt;&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #999999;&quot;&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;b&gt;
  
Lebih dari Satu Parameter:&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;/b&gt;&lt;/span&gt;&lt;!--CODE BLOCK--&gt;&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript&lt;/div&gt;&lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;const tambah = (a, b) =&amp;gt; a + b;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;
  
Biasanya dipakai untuk fungsi kecil yang sering digunakan.
Arrow Function dan Array
Arrow function sangat nyaman digunakan saat bekerja dengan array.

  &lt;/span&gt;&lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript&lt;/div&gt;&lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;const angka = [1, 2, 3, 4];
const hasil = angka.map(n =&amp;gt; n * 2);
console.log(hasil);&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;
  
Kode seperti ini mudah dipahami, bahkan saat dibaca ulang beberapa hari kemudian.
Contoh Penggunaan di DOM
Kasus yang sering ditemui saat membuat halaman interaktif.
&lt;/span&gt;&lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;Html&lt;/div&gt;&lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;  &amp;lt;button id=&quot;btn&quot;&amp;gt;Klik&amp;lt;/button&amp;gt;&lt;/div&gt;&lt;/div&gt;
&lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript&lt;/div&gt;&lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;  document.getElementById(&quot;btn&quot;).addEventListener(&quot;click&quot;, () =&amp;gt; {
  alert(&quot;Tombol diklik&quot;);
});&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;
Sederhana dan jelas.
Catatan Penting Tentang this
Ini bagian yang sering membingungkan, terutama untuk pemula.
Arrow function tidak memiliki this sendiri.
Contoh yang sering menimbulkan kebingungan:
&lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript&lt;/div&gt;&lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;const user = {
  nama: &quot;Budi&quot;,
  sapa: () =&amp;gt; {
    console.log(this.nama);
  }
};&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;
  
Hasilnya undefined, karena this tidak mengarah ke object user.
Jika membuat method di dalam object dan membutuhkan this, gunakan function biasa:
&lt;!--CODE BLOCK--&gt;
&lt;div style=&quot;background: rgb(248, 250, 252); border-radius: 8px; border: 1px solid rgb(226, 232, 240); margin: 16px 0px; overflow: auto;&quot;&gt;
  &lt;div style=&quot;background: rgb(238, 242, 255); border-bottom: 1px solid rgb(226, 232, 240); color: #3b82f6; font-size: 11px; font-weight: 600; line-height: 1.2; padding: 6px 12px;&quot;&gt;
    JavaScript
  &lt;/div&gt;
  &lt;div style=&quot;color: #0f172a; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6; padding: 10px 12px 12px; white-space: pre-wrap; word-break: break-word;&quot;&gt;const user = {
  nama: &quot;Budi&quot;,
  sapa: function () {
    console.log(this.nama);
  }
};&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #666666; font-family: helvetica;&quot;&gt;&lt;b&gt;
Kapan Arrow Function Sebaiknya Digunakan?&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Berdasarkan pengalaman, arrow function cocok digunakan untuk:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Callback
Event handler
Array method
Fungsi singkat
Dan sebaiknya dihindari untuk:&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Method object
Kasus yang membutuhkan this&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Penutup
Arrow function bukan sekadar gaya penulisan, tapi alat untuk membuat kode lebih nyaman dibaca dan dirawat.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;Bagi pemula, tidak perlu memaksakan diri menggunakannya di semua tempat.
Gunakan seperlunya, pahami pelan-pelan, dan praktikkan sesering mungkin.
&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: helvetica;&quot;&gt;&lt;span style=&quot;background-color: white; box-sizing: border-box; color: #686868; font-size: 16px;&quot;&gt;Di artikel selanjutnya, kita akan belajar&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; box-sizing: border-box; font-family: system-ui, -apple-system, &amp;quot;Segoe UI&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Arial, &amp;quot;Noto Sans&amp;quot;, &amp;quot;Liberation Sans&amp;quot;, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;; font-feature-settings: normal; font-kerning: auto; font-language-override: normal; font-optical-sizing: auto; font-size-adjust: none; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; line-height: normal; margin-bottom: 1.5rem !important; margin-top: 0px; text-align: left;&quot;&gt;&lt;a href=&quot;https://blog-cilik.blogspot.com/2026/01/tipe-data-javascript-lengkap-untuk-pemula.html&quot; target=&quot;_blank&quot;&gt;Tipe Data JavaScript Lengkap untuk Pemula Saat Ngoding&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://blog-cilik.blogspot.com/feeds/8421416911927580752/comments/default' title='Posting Komentar'/><link rel='replies' type='text/html' href='https://blog-cilik.blogspot.com/2025/12/arrow-function-javascript.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/8421416911927580752'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9024993991083531887/posts/default/8421416911927580752'/><link rel='alternate' type='text/html' href='https://blog-cilik.blogspot.com/2025/12/arrow-function-javascript.html' title='Arrow Function JavaScript'/><author><name>blogcilik</name><uri>http://www.blogger.com/profile/15754422881593101752</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></feed>