<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by iyal on Medium]]></title>
        <description><![CDATA[Stories by iyal on Medium]]></description>
        <link>https://medium.com/@firyalhfz?source=rss-1fe8f3db4fce------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*nrCeEAabCzwgX4GzMSMjdg.jpeg</url>
            <title>Stories by iyal on Medium</title>
            <link>https://medium.com/@firyalhfz?source=rss-1fe8f3db4fce------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 09:14:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@firyalhfz/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[hang in there.]]></title>
            <link>https://medium.com/@firyalhfz/hang-in-there-a95448e9c1f3?source=rss-1fe8f3db4fce------2</link>
            <guid isPermaLink="false">https://medium.com/p/a95448e9c1f3</guid>
            <dc:creator><![CDATA[iyal]]></dc:creator>
            <pubDate>Sat, 20 Sep 2025 13:49:40 GMT</pubDate>
            <atom:updated>2025-09-20T13:49:40.056Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8IN_GRmrnTLw1r5gPpRo7Q@2x.jpeg" /></figure><p>lately, i realize.</p><p>my mental is unstable,</p><p>soalnya bener bener males ngobrol sama orang, males buat reach out ke orang orang, males buat ngejelasin aku kenapa, kenapa aku ga bisa ngobrol, kenapa aku gabisa bales, kayak 😔🥺 rada sensi juga sama omongan orang, so i either stay silent, or ngomel..</p><p>sorry, i’m confused with myself too.</p><p>so if you ask me, are you okay yal? no i am not. tapi insya allah masi bisa kok melanjutkan perjalanan kehidupan ini. kemarin rada ketrigger buka twitter trus baca kasus yang suicide gegara some of problem, one of them is dibully ama temen temennya dan ngerasa sndiri😔 ya allah…. 🥺🥺</p><p>setiap org di muka bumi ini emng lagi berjuang yahh.. emang lagi pada capek,…. ada yang memilih untuk lanjut.. ada yang g sanggup buat lanjut 😔😔 so if we can’t be kind, at least stay quiet.. we dont know what people going through</p><p>hang in there guys, walau udah tidak ada semangat, at least idup aja. tetep makan, hirup udara segar, perhatikan hal hal kecil di idup, daun yang tertiup angin, sinar silau matahari, kucing kucing lucu..</p><p>kita usahakan untuk tetep sholat. sebejat bejatnya kita, semerasa kita ga pantas untuk berdoa, no no no, kita smua ni, deserve and should be, to go back to allah, untuk minta apapun di kondisi apapun.</p><p>lagi lagi semua yang kita rasakan ini, hal hal yang kita rasa buruk, mungkin bagi allah ini baik untuk kita. kejadian apapun yang menimpa kita. pasti, pasti ada hikmahnya. kalau tidak ditunjukan dikemudian hari, pasti allah kasi tau kelak dikehidupan selanjutnya kok..</p><p>love, someone who still tries 😢🫰🏻</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a95448e9c1f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Javascript Fundamentals]]></title>
            <link>https://medium.com/@firyalhfz/javascript-fundamentals-45a2c6e0d2c4?source=rss-1fe8f3db4fce------2</link>
            <guid isPermaLink="false">https://medium.com/p/45a2c6e0d2c4</guid>
            <dc:creator><![CDATA[iyal]]></dc:creator>
            <pubDate>Mon, 11 Jul 2022 08:45:51 GMT</pubDate>
            <atom:updated>2022-07-11T08:45:51.719Z</atom:updated>
            <content:encoded><![CDATA[<p>Tak terelakkan bahwa Javascript merupakan bahasa pemrograman yang paling populer. Yes, pembuatan website selain membutuhkan html, css, kita juga membutuhkan Javascript untuk membuat web kita lebih dinamis dan interaktif. Seperti apasih javascript itu? yuk, langsung kita bahas!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*Vubuafbth1IHbSgs" /></figure><h3>Sejarah Javascript</h3><p>JavaScript atau sering disingkat JS, pertama kali dibuat tahun 1995. Programmer di Netscape bernama Brandan Eich membuat sebuah bahasa pemrograman scripting untuk berjalan di Netscape Navigator Browser. Awalnya namanya adalah Mocha, lalu berubah menjadi LiveScript, dan akhirnya menjadi JavaScript.</p><p>JavaScript dibuat agar halaman website yang sudah kita buat menggunakan HTML dan CSS bisa lebih interaktif dan dinamis. Hal itu membuat web dan software Anda lebih mudah digunakan dan menarik bagi pengguna sehingga mereka lebih betah menggunakannya. Contoh tampilan dinamis pada website dan aplikasi contohnya slideshow foto, animasi, polling, tampilan scroll tanpa reload halaman, dan lain-lain.</p><p>JavaScript sekarang sudah mengalahkan Java Applet dan Flash sebagai bahasa pemrograman untuk membuat halaman web menjadi lebih interaktif, hal ini dikarenakan kemudahan bahasa nya dan juga secara default sekarang semua browser sudah bisa menjalankan JavaScript tanpa harus menginstall aplikasi tambahan seperti Java Applet dan Adobe Flash Player</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*Td9Ci1W_NPZVj0AW" /></figure><h3>Javascript di Server</h3><p>Awalnya JavaScript memang kebanyakan di gunakan untuk berjalan di client side (Browser) Namun akhir-akhir ini, semenjak keluar teknologi NodeJS yang bisa digunakan untuk menjalankan JavaScript tanpa browser, sekarang akhirnya JavaScript juga banyak digunakan untuk membuat aplikasi di Server</p><p>Karena ini, akhirnya sekarang JavaScript dikenal dengan bahasa pemrograman FullStack (Backend dan Frontend) karena bisa digunakan untuk membuat aplikasi Backend dan aplikasi Frontend</p><h3>Javascript dan ECMAScript</h3><p>Karena JavaScript sekarang hampir di adopsi oleh sebuah aplikasi browser, akhirnya dibuatlah sebuah standarisasi yang bernama ECMAScript. Organisasi yang melakukan standarisasi ECMAScript adalah ECMA International.</p><blockquote>ECMAScript dan JavaScript adalah dua nama untuk satu bahasa pemrograman yang sama.</blockquote><p>Sekarang dengan adanya standarisasi, kita bisa pastikan bahwa kode program JavaScript kita bisa jalan di semua browser, karena browser yang ingin mendukung JavaScript, harus mengikuti standarisasi ECMAScript.</p><h3>Tapi, sebelum itu..</h3><p>Saat kita belajar JavaScript, kita perlu menyiapkan beberapa perangkat lunak untuk membantu development</p><ul><li>Browser, bisa menggunakan Google Chrome, Firefox, Microsoft Edge, atau Safari, karena kita perlu menjalankan kode program JavaScript menggunakan Browser.</li><li>Text Editor atau Integrated Development Environment, ini digunakan untuk membuat kode program JavaScript, contoh: Visual studio code, sublime, Atom, WebStorm, Nodepad++</li></ul><h3>Hello world</h3><p>Ada beberapa cara untuk membuat kode JavaScript, Bisa langsung di file HTML, atau bisa menggunakan file .js (ekstensi untuk JavaScript), lalu di include di dalam file HTML. Pada praktek saat ini kita akan menggunakan HTML langsung agar mudah membuat kode program nya</p><ol><li>Hello world dalam satu file html:</li></ol><p>Kita bisa membuat code javascript dengan satu file html dan javascript, seperti contoh dibawah ini, document.writeln(&quot;hello world&quot;) berarti untuk menampilkan text hello world</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9bea23a8fdbacc57cc25fb57a83511fe/href">https://medium.com/media/9bea23a8fdbacc57cc25fb57a83511fe/href</a></iframe><p>2. Hello World dengan beda file</p><p>bisa gunakan dengan cara memanggil foldernya dalam tag script seperti berikut &lt;script src=&quot;scripts/hello-world.js&quot;&gt; &lt;/script&gt;</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/acb5a5f8f8699fd06299518479c2594a/href">https://medium.com/media/acb5a5f8f8699fd06299518479c2594a/href</a></iframe><p>Jika dijalankan di browser maka kita akan mendapatkan hasil seperti berikut:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zK_8sFQTho3wc6zTWjtwbg.png" /></figure><p>JavaScript mirip seperti bahasa pemrograman C/C++, dimana di akhir tiap statement kode program, kita perlu menambahkan ; (titik koma) Namun, di JavaScript tanda ; (titik koma) tidak wajib, jadi kita bisa menambahkan ataupun tidak.</p><h3>Komentar</h3><p>Komentar adalah kode program yang tidak akan dieksekusi ketika dibaca. Komentar biasanya digunakan sebagai informasi tambahan atau petunjuk. Di JavaScript, kita bisa menambahkan kode komentar.</p><p>Jika hanya butuh memberi komentar 1 baris maka tinggal menggunakan // jika butuh membuat komentar lebih dari dua baris maka bisa menggunakan /* */</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7d07de62664e22c44b1edbab3db95240/href">https://medium.com/media/7d07de62664e22c44b1edbab3db95240/href</a></iframe><h3>Tipe Data Number</h3><p>JavaScript hanya mendukung satu tipe data number, dimana tipe data number di JavaScript bisa berupa bilangan bulat atau bilangan desimal</p><p>Tidak seperti bahasa pemrograman yang lain termasuk Java dan C#, tipe data number di banyak bahasa pemrograman lain biasanya memiliki beberapa jenis, diantaranya integer, short, long, floating-point dan sebagainya. di JavaScript semuanya disatukan.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e7e41f7f40728a5db170cd801aa9c386/href">https://medium.com/media/e7e41f7f40728a5db170cd801aa9c386/href</a></iframe><h3>Tipe data Boolean</h3><p>Tipe data Boolean adalah tipe data yang hanya memiliki 2 nilai yaitu TRUE (benar) dan FALSE (salah). Walaupun tipe data boolean merupakan tipe data yang sangat sederhana, tapi tipe data boolean akan banyak digunakan di berbagai fitur pemrograman dalam membuat alur logika program.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/96a50e007950d657e96ab25cbdd50e0f/href">https://medium.com/media/96a50e007950d657e96ab25cbdd50e0f/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/0*TsYGL3kx_TCCUY1Y" /></figure><h3>Tipe data String</h3><p>Tipe data string atau text adalah tipe data yang berisikan kumpulan kosong atau lebih karakter. Sebelumnya kita sudah pernah menggunakan string ketika membuat program hello world.</p><p>Di JavaScript, untuk membuat data dengan tipe string, kita perlu menggunakan “ (petik dua) atau ‘ (petik satu) sebelum dan setelah isi text nya</p><p>Data string juga bisa digabung menggunakan operator + (plus)</p><p>JavaScript mendukung escape sequence di string. Escape sequence merupakan karakter khusus, seperti ENTER, TAB, “ (kutip dua), dan lain-lain. Berikut contoh escape sequence yang didukung oleh JavaScript di data string</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*evnRJxTXA4zetwQ9rn8GkQ.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/28d1260710cc225817c1c0c57037484c/href">https://medium.com/media/28d1260710cc225817c1c0c57037484c/href</a></iframe><p>maka kita akan mendapatkan hasil seperti berikut:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oax4RR07Z_aplgNfwpDWhg.png" /></figure><h3>Variable</h3><p>Variable adalah tempat untuk menyimpan data. Dengan menyimpan data di variable, kita bisa menggunakannya lagi dengan menyebutkan nama variable nya. Untuk membuat variable di JavaScript, kita bisa menggunakan kata kunci var diikuti dengan nama variable nya</p><p>JavaScript adalah dynamic language, artinya variable di JavaScript tidak terpaku harus menggunakan satu tipe data, kita bisa mengubah-ubah tipe data di variable yang sama.</p><p>Setelah variable di deklarasikan, kita bisa mengubah value atau nilai di dalam variable tersebut. Untuk mengubahnya, kita bisa menggunakan perintah nama variable diikuti dengan tanda = (sama dengan) lalu diikuti dengan value atau nilai nya. Jika kita mengubah data, kita tidak perlu sulit untuk mengubah semuanya. Catatan: ubah isi data variable sebelum di eksekusi</p><p>Salah satu keuntungan menggunakan variable adalah variable bisa digunakan kembali. Hal ini akan mempermudah ketika membutuhkan data yang sama berkali-kali. Untuk mengakses variable, kita cukup menyebutkan nama variable nya</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ecd7d21782f1e21844dfbed8e4dd38d/href">https://medium.com/media/6ecd7d21782f1e21844dfbed8e4dd38d/href</a></iframe><h3>Let dan const</h3><p>Sebelum tahun 2015, kata kunci untuk membuat variable hanya bisa menggunakan kata kunci var. Namun tahun 2015 sejak versi ECMAScript 2015, diperkenalkan kata kunci baru untuk membuat variable, let dan const</p><p>JavaScript sekarang tidak direkomendasikan lagi menggunakan kata kunci var untuk membuat variable, namun diganti dengan let, hal ini dikarenakan ada masalah dari desain awal var.</p><p>Kata kunci let itu seperti kata kunci var, dimana data di variable tersebut bisa diubah-ubah sesuka kita. Sedangkan kata kunci const berbeda, ketika sebuah variable sudah diisi di variable const, maka variable tersebut tidak bisa diubah lagi value nya. Variable sejenis ini kadang dibilang juga constant</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0dc9031cb67cb3a080ab82e8bfe56ae2/href">https://medium.com/media/0dc9031cb67cb3a080ab82e8bfe56ae2/href</a></iframe><h3>Operator Aritmatika</h3><p>Operator aritmatika adalah operator yang biasa digunakan pada operasi perhitungan otomatis, atau bisa disebut juga dengan operator yang digunakan juga untuk melakukan perhitungan.</p><p>Operator yang dimiliki javascript antara lain: Pertambahan, pengurangan, Perkalian, Exponensial, Pembagian dan sisa bagi</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4a53dd2528c27acaca998bb5c3634a09/href">https://medium.com/media/4a53dd2528c27acaca998bb5c3634a09/href</a></iframe><p>Kita bisa menambahkan string dan variable menggunakan (+). dan juga dapat memanggil variable-nya beberapa kali untuk di eksekusi lagi. Hasil yang di dapatkan dari code diatas adalah seperti berikut:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GOPn6PZ5Ujuaz51O0gPqig.png" /></figure><h3>Operator Augmented Assignments</h3><p>Operator assignment (penugasan) pada javascript, pengertian oprator assignment (penugasan) pada javascript adalah untuk mempersingkat operasi matematik, caranya ialah sama dengan memberikan nilai pada variable hanya saja ada operand dibagian kiri.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oKvlh_zSUUCg7AaBbrz_ew.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f9197e64326fd6df02bebacd3594ba61/href">https://medium.com/media/f9197e64326fd6df02bebacd3594ba61/href</a></iframe><p>untuk mempersingkat kodingan sebelumnya, kita bisa menggantinya dengan operator assignments, maka hasil yang akan kita dapatkan pun sama seperti contoh sebelumnya</p><h3>Operator Unary</h3><p>Operasi unary adalah operasi yang hanya memiliki satu operand. Operan ini muncul sebelum atau sesudah operator.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*poEg-xKSvga_c1DW0k7cXA.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/719e5bd26fd520e0b0f497bd33753f44/href">https://medium.com/media/719e5bd26fd520e0b0f497bd33753f44/href</a></iframe><p>Okayy, mungkin sekian dulu medium kita sampai pada materi operator, see u on another post! dont forget to make progress at least 1% everyday! happy coding! have a nice dayy!</p><p>Sumber:</p><ul><li><a href="https://idcloudhost.com/apa-itu-javascript/">Apa Itu JavaScript? Fungsi, Kelebihan dan Kekurangannya</a></li><li><a href="https://www.ecma-international.org/">Home - Ecma International</a></li><li><a href="https://bahasaweb.com/operator-assignment-pada-javascript/">Operator Assignment (Penugasan) Pada JavaScript</a></li></ul><p><a href="https://www.gotutorid.com/javascript/op-aritmatika/">https://www.gotutorid.com/javascript/op-aritmatika/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45a2c6e0d2c4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sets and Maps in javascript]]></title>
            <link>https://medium.com/@firyalhfz/sets-and-maps-in-javascript-ea8526cc2e03?source=rss-1fe8f3db4fce------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea8526cc2e03</guid>
            <dc:creator><![CDATA[iyal]]></dc:creator>
            <pubDate>Sat, 26 Mar 2022 15:12:24 GMT</pubDate>
            <atom:updated>2022-03-29T17:43:03.649Z</atom:updated>
            <content:encoded><![CDATA[<p>We have talked about arrays and objects. They are the most important data structures to handle collections of data.</p><p>arrays: an ordered collection that can hold data of any type. created with square brackets []</p><p>objects: a list of properties (key and value) used to store multiple values as a complex data structure. created with curly braces {}</p><p>But, that&#39;s not enough for some cases.</p><ul><li>Object keys can only be of type string.</li><li>Objects don’t maintain the order of the elements inserted into them.</li><li>Objects lack some useful methods, which makes them difficult to use in some situations. For example, you can’t compute the size (length) of an object easily. Also, enumerating an object is not that straightforward.</li><li>Arrays are collections of elements that allow duplicates. Supporting arrays that only have distinct elements requires extra logic and code.</li></ul><p>Because of that…. in ES6 there are 2 new data structures: <strong>Map and Set. </strong>lets talk about it one by one!</p><h3>Sets</h3><p>Set is basically just a collection of <strong>unique values</strong>. So that means a set can never have any duplicates. Each value can only <strong>occur once</strong> in a Set. A Set in JavaScript behaves the same way as a mathematical set.</p><p><a href="https://javascript.info/map-set">According to javascript-info.</a> A Set is a special type collection – “set of values” (without keys), where each value may occur only once.</p><h4>Syntax</h4><p>The syntax of the sets is simple variable_name = new Set([‘value’, ‘value’])</p><pre>const ordersSet = new Set([&#39;Pasta&#39;, &#39;Pizza&#39;, &#39;Pizza&#39;, &#39;Sphagetti&#39;, &#39;Pasta&#39;]);<br>console.log(ordersSet);</pre><pre>//Set(3) {&#39;Pasta&#39;, &#39;Pizza&#39;, &#39;Sphagetti&#39;}</pre><h4>Check the size of set:</h4><p>We can see how many properties inside our set, use size</p><pre>console.log(ordersSet.size); // 3</pre><h4>Check existance of value:</h4><p>To check if the value does exist or not in our set, use has method</p><pre>console.log(ordersSet.has(&#39;mcd&#39;)); // false<br>console.log(ordersSet.has(&#39;Pizza&#39;)); // true</pre><h4>Add the value:</h4><p>To add the value to the set, use add method</p><pre>ordersSet.add(&#39;Garlic Bread&#39;);</pre><h4>Delete the value:</h4><p>We can also delete the value of the set, use the delete method</p><pre>ordersSet.delete(&#39;Sphagetti&#39;);</pre><h4>No index in set!</h4><p>We can create an array around the set</p><pre>const staff = [&#39;Waiter&#39;, &#39;Chef&#39;, &#39;Waiter&#39;, &#39;Manager&#39;, &#39;Chef&#39;, &#39;Water&#39;];</pre><p>In the sets, there are <strong>actually no indexes</strong>. And in fact, there is no way of getting values out of a set. We cannot call set one by one, but we can use the array to call it. <strong>Unpack this entire set using spread operator:</strong> […new Set(variable_name)]. then, the element will be put into the newly constructed array.</p><pre>const staffUnique = [...new Set(staff)];<br>console.log(staffUnique); // (4) [&#39;Waiter&#39;, &#39;Chef&#39;, &#39;Manager&#39;, &#39;Water&#39;]</pre><pre>console.log(new Set(staff).size); // 4</pre><blockquote>So in a normal code base, the main use case of sets is actually to remove duplicate values of arrays.</blockquote><h3>Maps</h3><p>A map is a data structure that we can <strong>use to map values to keys</strong>. <a href="https://www.w3schools.com/js//js_maps.asp">A Map holds</a> key-value pairs where the keys can be any datatype. A Map remembers the original insertion order of the keys. The map is Like an object, it supports the <strong>key-value pair structure</strong> and Like an array, it <strong>remembers the insertion order</strong>.</p><p>Just like an object data is stored in key-value pairs in maps. Now, the big difference between objects and maps is that in maps,<strong> the keys can have any type</strong> and this can be huge.</p><blockquote>In objects, the keys are basically always strings. But in maps, we can have any type of key. It could even be objects or arrays or other maps.</blockquote><h4>Syntax</h4><p>The syntax to make map, syntax: const variable_name = new Map(); and to fill up data to the map, use key method: variable_name.set(key, value);</p><pre>const aot = new Map();<br>aot.set(&#39;name&#39;, &#39;Eren Yeager&#39;);<br>aot.set(1, &#39;Paradis&#39;);<br>aot.set(2, &#39;Marley&#39;);<br>aot.set(&#39;friends&#39;, [&#39;Mikasa&#39;, &#39;Armin&#39;, &#39;Jean&#39;, &#39;Connie&#39;, &#39;Sasha&#39;]);<br>console.log(aot);</pre><pre>/**</pre><pre>* Map(5) {&#39;name&#39; =&gt; &#39;Eren Yeager&#39;, 1 =&gt; &#39;Paradis&#39;, 2 =&gt; &#39;Marley&#39;, &#39;friends&#39; =&gt; Array(5), 3 =&gt; &#39;Eldian&#39;}</pre><pre>*/</pre><h4>Read data map</h4><p>To read data from map, use get method: variable_name.get(key)</p><pre>console.log(aot.get(&#39;name&#39;)); // Eren Yeager<br>console.log(aot.get(1)); // Paradis</pre><h4>Delete value</h4><p>To delete one of the value, use delete method: variable_name.delete(key) and if want to delete all of the value, use clear method: variable_name.clear()</p><pre>aot.delete(2); <br>aot.clear();</pre><h4>Check certain key</h4><p>To check if a map contains a certain key, use has method: variable_name.has(key)</p><pre>console.log(aot.has(&#39;friends&#39;)); // true</pre><h4>Another example…</h4><p>For another example, you can see we have new rest Map() and contains key open, close, and boolean. We can compare the current time with open and close to get the string that we want. When we pass in false we will get closed, when we pass in true we will get open.</p><pre>const rest = new Map();<br>rest<br>.set(&#39;open&#39;, 8)<br>.set(&#39;close&#39;, 22)<br>.set(true, &#39;We are open&#39;)<br>.set(false, &#39;We are closed&#39;);</pre><pre>console.log(rest.get(true)); // we are open</pre><pre>const time = 24;<br>console.log(rest.get(time &gt;= rest.get(&#39;open&#39;) &amp;&amp; time &lt;= rest.get(&#39;close&#39;))); // we are closed</pre><p>But in the last console.log, It is not always really readable, so don&#39;t overuse this kind of pattern.</p><h4>Arrays/Objects as map keys</h4><p>We can use arrays or objects as map keys. First, we have to make variable array as a key. Second, we set the value of that array. Last, we get the value by using get() inside the parenthesis call variable array (arr)</p><pre>const arr = [1, 2];<br>aot.set(arr, &#39;Test&#39;);</pre><pre>console.log(aot.get(arr)); // Test</pre><h3>Maps Iteration</h3><p>The methods keys(), values() and entries() methods return a MapIterator, which is excellent because you can use a for-of or forEach loop directly on it.</p><p>We can make a <strong>new map without using the set method</strong>. We make arrays inside the array and elements. For example, We make arrays inside the map for the question, answer, correct answer, and boolean when correct so string correct, and if wrong then try again.</p><pre>const question = new Map([<br>  [&#39;question&#39;, &#39;What is the best programming language is the   world?&#39;],<br>  [1, &#39;C&#39;],<br>  [2, &#39;Java&#39;],<br>  [3, &#39;Javascript&#39;],<br>  [&#39;correct&#39;, 3],<br>  [true, &#39;Correct&#39;],<br>  [false, &#39;Try again!&#39;],<br>]);</pre><p>If we console it we will get results:</p><pre>console.log(question);</pre><pre>//Map(7) {&#39;question&#39; =&gt; &#39;What is the best programming language is the world?&#39;, 1 =&gt; &#39;C&#39;, 2 =&gt; &#39;Java&#39;, 3 =&gt; &#39;Javascript&#39;, &#39;correct&#39; =&gt; 3, …}</pre><p>Actually the map question is exactly the same array structure that is returned from the calling object.entries(). <strong>We get an array of arrays</strong> where the first element is the key and the second one is the value. So its means is there is an <strong>easy way to convert from objects to maps.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea8526cc2e03" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Looping objects: object keys, values, and entries]]></title>
            <link>https://medium.com/@firyalhfz/looping-objects-object-keys-values-and-entries-e11f1a7fd26a?source=rss-1fe8f3db4fce------2</link>
            <guid isPermaLink="false">https://medium.com/p/e11f1a7fd26a</guid>
            <dc:creator><![CDATA[iyal]]></dc:creator>
            <pubDate>Tue, 15 Mar 2022 14:28:37 GMT</pubDate>
            <atom:updated>2022-03-15T14:28:37.808Z</atom:updated>
            <content:encoded><![CDATA[<p>We have already learn about <a href="https://medium.com/@firyalhuwaida/looping-arrays-the-for-of-loop-d81ead00bc9a">for-of loop</a>. Now, we will learning about how to loop over the objects, property names over the values or both together.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eSgIgO4Zwr2FccMzC_4Xmg.jpeg" /></figure><h3>Example of the object</h3><pre>const openingHours = {<br> thu: {<br>   open: 12,<br>   close: 22,<br> },<br> fri: {<br>   open: 11,<br>   close: 23,<br> },<br> sat: {<br>   open: 0, // Open 24 hours<br>   close: 24,<br> },<br>};</pre><h3>Object.keys()</h3><p>The Object.keys() method returns an array of a given object&#39;s own enumerable property names, iterated in the same order that a normal loop would.</p><pre>// Property NAMES<br>const properties = Object.keys(openingHours);<br>console.log(properties); </pre><pre>// (3) [&#39;thu&#39;, &#39;fri&#39;, &#39;sat&#39;]</pre><p>Object.keys() returns an array whose elements are strings corresponding to the enumerable properties found directly upon object. The ordering of the properties is the same as that given by looping over the properties of the object manually.</p><h3>Object.values()</h3><p>The Object.values() method returns an array of a given object&#39;s own enumerable property values.</p><pre>// Property VALUES<br>const values = Object.values(openingHours);<br>console.log(values);</pre><pre>/*<br>[<br>  { open: 12, close: 22 },<br>  { open: 11, close: 23 },<br>  { open: 0, close: 24 }<br>]<br>*/</pre><p>Object.values() returns an array whose elements are the enumerable property values found on the object. The ordering of the properties is the same as that given by looping over the property values of the object manually.</p><h3>Object.entries()</h3><p>The Object.entries() method returns an array of a given object&#39;s own enumerable string-keyed property [key, value] pairs.</p><pre>//ENTRIES object<br>const entries = Object.entries(openingHours);<br>console.log(entries);</pre><pre>/**<br>  [<br>    [ &#39;thu&#39;, { open: 12, close: 22 } ],<br>    [ &#39;fri&#39;, { open: 11, close: 23 } ],<br>    [ &#39;sat&#39;, { open: 0, close: 24 } ]<br>  ]<br> */</pre><p>Object.entries() returns an array whose elements are arrays corresponding to the enumerable string-keyed property [key, value] pairs found directly upon object. The ordering of the properties is the same as that given by looping over the property values of the object manually.</p><h3>Use all together</h3><pre>//[key, value]<br>//for of the entries [key, value]<br>for (const [day, {open, close}] of entries){<br>  console.log(`On ${day} we open at ${open} and close at ${close}`);<br>}</pre><pre>/**<br> * On thu we open at 12 and close at 22<br> * On fri we open at 11 and close at 23<br> * On sat we open at 0 and close at 24<br> */</pre><p>Reference:<br><a href="https://www.udemy.com/course/the-complete-javascript-course/learn/lecture/22648577#overview">https://www.udemy.com/course/the-complete-javascript-course</a></p><p><a href="https://javascript.info/keys-values-entries">https://javascript.info/keys-values-entries</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e11f1a7fd26a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optional Chaining (?.)]]></title>
            <link>https://medium.com/@firyalhfz/optional-chaining-e8eeb9a811e?source=rss-1fe8f3db4fce------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8eeb9a811e</guid>
            <dc:creator><![CDATA[iyal]]></dc:creator>
            <pubDate>Tue, 15 Mar 2022 13:42:37 GMT</pubDate>
            <atom:updated>2022-03-15T13:42:37.347Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*bylzA938hUVX3jCa" /><figcaption>picture by <a href="https://unsplash.com/@simonesecci">@simonesecci</a> in <a href="https://unsplash.com/photos/49uySSA678U">unsplash</a></figcaption></figure><p>Optional chaining is one of the newer feature of objects and also of arrays. So what is it?<strong> The </strong><a href="https://www.geeksforgeeks.org/javascript-optional-chaining/"><strong>optional chaining (?.</strong></a><strong>) is an error-proof way to access nested object properties, even if an intermediate property doesn&#39;t exist.</strong></p><p>Use this enables us to read the value of a property located deep within a chain of connected objects without having to check that each reference on the chain is valid. The reference is nullish (null or undefined).</p><blockquote>Optional chaining is an alternative to forced unwrapping</blockquote><h3>Yeah okay, so how do we use it?</h3><p>For example we have the object restaurant that define the property inside using the openingHours object.</p><pre>const weekdays = [&#39;mon&#39;, &#39;tue&#39;, &#39;wed&#39;, &#39;thu&#39;, &#39;fri&#39;, &#39;sat&#39;, &#39;sun&#39;];</pre><pre>const openingHours = {<br>  thu: {<br>    open: 12,<br>    close: 22,<br>  },<br>  fri: {<br>    open: 11,<br>    close: 23,<br>  },<br>  sat: {<br>    open: 0, // Open 24 hours<br>    close: 24,<br>  },<br>};</pre><pre>const restaurant = {<br>  openingHours,<br>};</pre><p>We want to check the openingHours of Monday. We check it with if statement. but it&#39;s too complicated and so long code. We have to double-check, first check the object of openingHours does it exist or not, and check the mon does it exist or not.</p><pre>if (restaurant.openingHours &amp;&amp; restaurant.openingHours.mon)<br> console.log(restaurant.openingHours.mon.open);</pre><p>Actually, we can check with chaining operators, it&#39;s simpler. just put the question mark (?) after the object properties, to check does the object properties exist or not.</p><pre>console.log(restaurant.openingHours?.mon?.open);</pre><p>With optional chaining, if a certain property does not exist, then undefined is returned immediately.</p><h3>Another example…</h3><p>for another example, we can use the nullish coalescing operator to get back to open at 0. If the item to the left of ?? is nullish, the item to the right will be returned.</p><p>We know that if any ?. check equates to a nullish value within the chain, it will return undefined. So we can use our nullish coalescing to respond to the undefined outcome and set an explicit fallback value.</p><pre>const days = [&#39;mon&#39;, &#39;tue&#39;, &#39;wed&#39;, &#39;thu&#39;, &#39;fri&#39;, &#39;sat&#39;, &#39;sun&#39;];<br>for (const day of days) {<br>  // console.log(day);<br>  const open = restaurant.openingHours[day]?.open ?? &#39;closed&#39;;<br>  console.log(`On ${day}, we open at ${open}`);<br>}</pre><p>So the result in our console will be like this</p><pre>On mon, we open at closed<br>On tue, we open at closed<br>On wed, we open at closed<br>On thu, we open at 12<br>On fri, we open at 11<br>On sat, we open at 0<br>On sun, we open at closed</pre><h3>Method</h3><p>We can use optional chaining when attempting to call a method that may not exist. This can be helpful, for example, when using an API in which a method might be unavailable, either due to the age of the implementation or because of a feature that isn’t available on the user’s device.</p><pre>console.log(restaurant.order?.(0, 1) ?? &#39;Method does not exist&#39;);<br>console.log(restaurant.orderRisotto?.(0, 1) ?? &#39;Method does not exist&#39;);</pre><h3>Array</h3><p>We also can use optional chaining when attempting to call an array that may not exist.</p><pre>const users = [{name: &#39;Firyal&#39;, email: &#39;<a href="/service/mailto:firyal@gmail.com">firyal@gmail.com</a>&#39;}]</pre><pre>//use optional chaining <br>console.log(users[0]?.name ?? &#39;user array empty&#39;);</pre><pre>//if using if else <br>if(users.length &gt; 0) console.log(users[0].name);<br>else console.log(&#39;user array empty&#39;);</pre><p>As I told you last time, we can use the if-else to check the array does exist or not, and yeah we can also use the optional chaining to check the condition. But, better if you don’t use all the check conditions of your code using the optional chaining because maybe later the other developer cannot read your code, or maybe you will confuse about your code later. <a href="https://stackoverflow.com/questions/56235254/optional-vs-if-else-if-performance-java-8">Read this</a>.</p><h3>Reference:</h3><p><a href="https://www.udemy.com/course/the-complete-javascript-course/learn/lecture/22648573#overview">https://www.udemy.com/course/the-complete-javascript-course/</a></p><ul><li><a href="https://www.freecodecamp.org/news/javascript-optional-chaining/">How to Use Optional Chaining in JavaScript</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining">Optional chaining (?.) - JavaScript | MDN</a></li><li><a href="https://www.geeksforgeeks.org/javascript-optional-chaining/">JavaScript | Optional chaining - GeeksforGeeks</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8eeb9a811e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enhanced Object Literals in Javascript]]></title>
            <link>https://medium.com/@firyalhfz/enhanced-object-literals-in-javascript-b03e5890b39f?source=rss-1fe8f3db4fce------2</link>
            <guid isPermaLink="false">https://medium.com/p/b03e5890b39f</guid>
            <dc:creator><![CDATA[iyal]]></dc:creator>
            <pubDate>Tue, 15 Mar 2022 10:18:50 GMT</pubDate>
            <atom:updated>2022-03-15T10:18:50.888Z</atom:updated>
            <content:encoded><![CDATA[<p>New features introduced from ES6 make object handling even easier in all modern browsers. Object literals that we can do there are:</p><ul><li>Defining properties</li><li>Defining methods</li><li>Computed property Names</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EUUhUK5sJ_MMptE8cCtVEQ.jpeg" /></figure><h3>Defining Properties</h3><p>We can just make property as the object that we made outside the object.</p><p>For example we have openingHours Object and restaurant Object. We can actually make the openingHours Object, become property in restaurant Object. taraa look amazing right?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pp8H7dg0z5wcLqQi0RQrew.png" /><figcaption>Defining Object</figcaption></figure><h3>Defining methods</h3><p>Before ES6 when we defining a method inside the object literal we did like orderPizza: function() {} Now, in ES6 its simpler. We no longer have to create a property, and then set it to a function expression.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kw_xJ_pkmVHcnXRi17ecxA.png" /><figcaption>defining methods</figcaption></figure><h3>Computed property Names</h3><p>In ES6 we can compute property names instead of having to write them out manually an literally.</p><p>We can do as we want, like [weekdays[3]], also put the `` and many others!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Q45Ax-fHb68iEeHxp3f2A.png" /><figcaption>computed property names</figcaption></figure><p>Yoshh! that&#39;s it. Thankyou for reading! you can see the code <a href="https://github.com/firyalhuwaida/learn-javascript/commit/de0f69f1ff3bec8b1abeb3f86d14644f2754cb7f">here</a>. See my another <a href="https://github.com/firyalhuwaida/">repository github</a>. Keep coding and see you on another post!</p><h3>Reference</h3><ul><li><a href="https://www.sitepoint.com/es6-enhanced-object-literals/">ES6 in Action: Enhanced Object Literals - SitePoint</a></li><li><a href="https://www.geeksforgeeks.org/javascriptes6-object-literal-enhancement/">JavaScript(ES6) | Object Literal Enhancement - GeeksforGeeks</a></li><li><a href="https://www.c-sharpcorner.com/blogs/javascriptes6-enhance-object-literals">JavaScript Enhance Object Literals (ES6)</a></li></ul><p><a href="https://www.udemy.com/course/the-complete-javascript-course/learn/lecture/22648565#content">https://www.udemy.com/course/the-complete-javascript-course</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b03e5890b39f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Looping Arrays (The for-of Loop)]]></title>
            <link>https://medium.com/@firyalhfz/looping-arrays-the-for-of-loop-d81ead00bc9a?source=rss-1fe8f3db4fce------2</link>
            <guid isPermaLink="false">https://medium.com/p/d81ead00bc9a</guid>
            <dc:creator><![CDATA[iyal]]></dc:creator>
            <pubDate>Tue, 15 Mar 2022 09:55:38 GMT</pubDate>
            <atom:updated>2022-03-15T10:01:38.473Z</atom:updated>
            <content:encoded><![CDATA[<p>There is a new way for looping array! This was introduced in <em>ES6</em>. What is it? It is the <strong>for-of loop</strong>. The Javascript for of statement loops through the values of an iterable object. It lets us<strong> loop over iterable data structures such as arrays, string, array-like objects (arguments),</strong> and others. It invokes a custom iteration hook with statements to be executed for the value of each distinct property of the object.</p><h3>The syntax:</h3><p><strong>variable</strong> — For every iteration, the value of the next property is assigned to the variable. <em>Variable</em> can be declared with const, let, or var.</p><p><strong>iterable</strong> — An object that has iterable properties.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/1*pMJ_yoD1qCYc81UXcOcdJQ.png" /><figcaption>syntax</figcaption></figure><h3>For-of looping Arrays</h3><p>We have some properties array. We want to log the all of menu in starterMenu and mainMenu. First, we can use <a href="https://medium.com/@firyalhuwaida/the-spread-operator-in-javascript-c0fe6f0f8a02">spread operator</a> to spread the array of starterMenu and mainMenu, after that we can use for-of looping to console it. We make a new variable item using const, and console the item.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GlLooSz0-aQ2KUHurxxY_Q.png" /><figcaption>for-of looping array</figcaption></figure><p>The result is will be like this:</p><pre>Focaccia<br>Bruschetta<br>Garlic Bread<br>Caprese Salad<br>Pizza<br>Pasta<br>Risotto</pre><h3>The object.entries()</h3><p>The Object.entries() method returns an array of a given object&#39;s own enumerable string-keyed property [key, value] pairs.</p><p>We can see the example of using entries() below. We type menu.entries() inside the for-of looping. and</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FJR0XVYEb3zHOB_cuQh6rg.png" /><figcaption>object.entried()</figcaption></figure><p>We will get the arrays result of the [key and value]:</p><pre>[ 0, &#39;Focaccia&#39; ]<br>[ 1, &#39;Bruschetta&#39; ]<br>[ 2, &#39;Garlic Bread&#39; ]<br>[ 3, &#39;Caprese Salad&#39; ]<br>[ 4, &#39;Pizza&#39; ]<br>[ 5, &#39;Pasta&#39; ]<br>[ 6, &#39;Risotto&#39; ]</pre><p>Another example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tZh4TeaLsgRw7BCfvObLmA.png" /><figcaption>another example</figcaption></figure><h3>Reference</h3><ul><li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries">Object.entries() - JavaScript | MDN</a></li><li><a href="https://www.w3schools.com/js/js_loop_forof.asp">JavaScript For Of</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of">for...of - JavaScript | MDN</a></li></ul><p><a href="https://www.udemy.com/course/the-complete-javascript-course/learn/lecture/22648563#content">https://www.udemy.com/course/the-complete-javascript-course/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d81ead00bc9a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Short-Circuiting (&& ||) and Nullish Coalescing Operator (??)]]></title>
            <link>https://medium.com/@firyalhfz/short-circuiting-and-nullish-coalescing-operator-27343f6803bd?source=rss-1fe8f3db4fce------2</link>
            <guid isPermaLink="false">https://medium.com/p/27343f6803bd</guid>
            <dc:creator><![CDATA[iyal]]></dc:creator>
            <pubDate>Mon, 14 Mar 2022 09:35:16 GMT</pubDate>
            <atom:updated>2022-03-14T09:35:16.793Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://dev.to/saran_chakravarthi/javascript-demystified-short-circuiting-nullish-coalescing-and-optional-chaining-1e4n">Short-circuiting</a> can be defined as the phenomenon in programming by which the compiler or the interpreter skips the evaluation of the sub-expressions in an expression, as soon as it determines the final result of that expression.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DmEeA5--YG9whNM90rOGYA.jpeg" /></figure><h3>OR operator</h3><p>The OR operator returns true if at least one of the values is truthy. So, as soon as JavaScript encounters a truthy value, it can stop evaluating the expression.</p><p>OR operator short-circuiting means that if the first value is a truthy value, it will immediately return that first value and the other operand will not even be evaluated. No matter how many values (zero, empty string, undefined, null, string hai) the result is always the truthy value. If the all of the value is falsy, so just return the last falsy value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F-WrBfplDdS2puURVeN_0g.png" /><figcaption>OR operator</figcaption></figure><p>For another example, we have an object that we also use in the last medium post. That object contains many properties. Such as name, location, categories, starterMenu, mainMenu. On the outside of the object we make a new variable guest that calls the object and needs numGuest property, Does that exist? We don&#39;t know, so we can check that using ternary operator, and new things we can do is, using OR OPERATOR. we can see in this line code const guest2 = restaurant.numGuests || 10; We use OR operator to check the condition if the numGuest is exist so print it, if not so just print 10.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*biuFm-EnP6pmmrytYbNBDA.png" /><figcaption>OR Operator</figcaption></figure><blockquote>OR operator will return the first truthy value of all the operands, or simply the last value if all of them are falsy. Can use the OR operator to set default values</blockquote><h3>AND Operator</h3><p>AND operator will return true only if all the values are true. So, it can safely return false, as soon as it encounters a falsy value. It does not have to check other values, because if one of the values is falsy, the entire expression will turn out to be false. But, if the values is truthy so the print is will be the last truthy value. You can see the example here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XPZN4mz8O4rbv5YpqvUQDQ.png" /><figcaption>AND operator</figcaption></figure><p>Another example of &amp;&amp; operator. We want to check the method of orderPizza() is exists or not. First, we can use the if-else, and we also can use the &amp;&amp; operator. So if the method orderPizza does exist print the argument that we make, mushroom and spinach.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZlQSAqOxib_K9ic9_v70yA.png" /><figcaption>And operator</figcaption></figure><blockquote>the AND operator will return the first falsy value or the last value if all of them are truthy. Can use the AND operator to execute code in the second operand if the first one is true.</blockquote><h3>Nullish coalescing operator.</h3><p>The nullish coalescing(??) is very similar to the logical OR operator. The difference is nullish coalescing operator treats null and undefined as falsy values and everything else as truthy values.</p><p>You can see the code below, it&#39;s similar with the or operator, but if or operator will change the value if falsy value(undefined, null, 0, empty string). Nullish coalescing is different, it just null and undefined, so if the value is 0 it will print 0 and don&#39;t change the value.</p><p>Well, it is because the nullish coalescing operator works with the idea or with the concept of nullish values instead of falsy values. And nullish values are null and undefined. So basically, for the nullish coalescing operator, it is as if the zero and the empty string were not falsy values and were instead truthy values as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cPGqwDlwHvzizXxLFRkJMA.png" /><figcaption>nullish value</figcaption></figure><p><a href="https://github.com/firyalhuwaida/learn-javascript/blob/master/data-structures-operators/script.js">source code</a>. keep coding and see you on another post!</p><p>Reference:</p><p><a href="https://dev.to/saran_chakravarthi/javascript-demystified-short-circuiting-nullish-coalescing-and-optional-chaining-1e4n">JavaScript Demystified: Short-circuiting, nullish coalescing and Optional chaining</a></p><p><a href="https://www.udemy.com/course/the-complete-javascript-course/learn/lecture/22648553#content">https://www.udemy.com/course/the-complete-javascript-course</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27343f6803bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rest Pattern and parameters in Javascript]]></title>
            <link>https://medium.com/@firyalhfz/rest-pattern-and-parameters-in-javascript-dfa7038f11a8?source=rss-1fe8f3db4fce------2</link>
            <guid isPermaLink="false">https://medium.com/p/dfa7038f11a8</guid>
            <dc:creator><![CDATA[iyal]]></dc:creator>
            <pubDate>Mon, 14 Mar 2022 06:55:43 GMT</pubDate>
            <atom:updated>2022-03-14T06:57:06.239Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zs3LGZNVcXjGRfc5TtD1LQ.jpeg" /></figure><p>According to <a href="https://www.geeksforgeeks.org/javascript-rest-operator/">geeks for geeks</a>, the <strong>Rest parameter</strong> is an improved way to handle function parameters, allowing us to more easily handle various inputs as parameters in a function. The rest parameter syntax allows us to represent an indefinite number of arguments as an array. With the help of a rest parameter, a function can be called with any number of arguments, no matter how it was defined. Rest parameter is added in ES2015 or ES6 which improved the ability to handle parameter.</p><p>The rest pattern looks exactly like the spread operator, so it has the same syntax with the three dots but it actually does the opposite of the spread operator.</p><p>Remember that we used the spread operator to build new arrays or to pass multiple values into a function. So those are the two use cases of the spread operator and in both cases, <strong>we use the spread operator to expand an array into individual elements. </strong>Now, the rest pattern uses the exact same syntax, however, to collect multiple elements and condense them into an array.</p><p>That’s really the opposite of spread, The spread operator is to unpack an array while the rest is to pack elements into an array, and since that sounds really confusing let’s write some coat and let’s start by exploring the use case of building a race.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jVkbqvQWrc80UVuUuXWKYw.png" /><figcaption>rest pattern</figcaption></figure><blockquote>the rest pattern basically collects the elements that are unused in the destructuring assignment.</blockquote><p>Another example of rest</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JL4xu9z4q0OQWz4Y6VumNg.png" /><figcaption>rest patterm</figcaption></figure><p>The rest syntax is taking multiple numbers or multiple values and then packing them all into one array.</p><p>Another example that object. we want to call the weekdays so we can like the code below {sat, …weekdays} it make our fri and sat become in weekdays object, we can directly call weekdays</p><p>So, the result is {thu: {…}, fri: {…}} because we just call the weekdays.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cP7vWyn7YsJ62HvnBlDYvg.png" /><figcaption>example object rest operators</figcaption></figure><p>The rest parameter syntax allows a function to accept an indefinite number of arguments as an array, providing a way to represent <a href="https://en.wikipedia.org/wiki/Variadic_function">variadic functions</a> in JavaScript. We can <strong>pass multiple arguments into a function</strong> all at the same time.</p><p>A function definition’s last parameter can be prefixed with “...&quot;, which will cause all remaining (user supplied) parameters to be placed within a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">standard JavaScript array</a>. Only the last parameter in a function definition can be a rest parameter.</p><p>For example, we had an array and then we expanded all of these elements of the array to basically pass these elements then as individual arguments of the function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*siQ357GO4vYjX_38JMeUKw.png" /><figcaption>function example</figcaption></figure><p>Another example of rest parameters:</p><p>For example, we have function order pizza, and we create 2 parameters, the first parameter is mainIngredient, the last parameter, is using rest parameters (…) so that we can collect the other mainIngredient inside the otherIngredients</p><p>The result is, if we just call the function and pass many arguments, the first argument will become mainIngredient and the other arguments will become otherIngredients. but if we just pass one argument, so we will get first argument become mainIngredient, and otherIngredient will be empty array</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hsdtz3-pIyb9LrZbYmFrBg.png" /></figure><p>Oke, its finished, see you in another post, you can see the source code <a href="https://github.com/firyalhuwaida/learn-javascript/blob/master/data-structures-operators/script.js">here</a>. Dont forget to make at least 1% progress everyday, #keepcoding #learntogether</p><p>my github:</p><p><a href="https://github.com/firyalhuwaida/">firyalhuwaida - Overview</a></p><h3>Reference</h3><ul><li><a href="https://www.geeksforgeeks.org/javascript-rest-operator/">JavaScript | Rest parameter - GeeksforGeeks</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters">Rest parameters - JavaScript | MDN</a></li></ul><p><a href="https://www.udemy.com/course/the-complete-javascript-course/learn/lecture/22648543#content">https://www.udemy.com/course/the-complete-javascript-course/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dfa7038f11a8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Spread Operator in Javascript]]></title>
            <link>https://medium.com/@firyalhfz/the-spread-operator-in-javascript-c0fe6f0f8a02?source=rss-1fe8f3db4fce------2</link>
            <guid isPermaLink="false">https://medium.com/p/c0fe6f0f8a02</guid>
            <dc:creator><![CDATA[iyal]]></dc:creator>
            <pubDate>Mon, 14 Mar 2022 02:17:04 GMT</pubDate>
            <atom:updated>2022-03-14T02:17:04.832Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TT9Gg8Q-en6YTaeLii9YOA.jpeg" /></figure><p>The spread operator basically expands an array into all its elements, unpacking all the array elements at one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ybbpLthj4_uNbxAgnRzCBw.png" /></figure><p>You can see an example in the above code,<strong> we expand an array.</strong> so new Array, we get the exact same result with badnews array. Spread operate does is to basically take all the values out of this arr and then write them individually as if we wrote seven, eight, nine manually.</p><blockquote>Spread operator using three dots (…)</blockquote><p>We can use spread operator whenever we would otherwise write multiple values separated by commas.</p><p>Second things that we can do with spread operator is we can <strong>pass arguments into functions.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3xFNclnMtRkgCqF7OHKjuw.png" /></figure><h3>What else can … do?</h3><p>The … spread operator is useful for many different routine tasks in JavaScript, including the following:</p><ul><li>Copying an array</li><li>Concatenating or combining arrays</li><li>Using Math functions</li><li>Using an array as arguments</li><li>Adding an item to a list</li><li>Adding to state in React</li><li>Combining objects</li><li>Converting NodeList to an array</li></ul><p>In each case, the spread syntax expands an iterable object, usually an array, though it can be used on any iterable, including a string.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P562mnMSBJwtLjtLyOY8NA.png" /></figure><p>One of the benefits of using the spread operator is that it will create a new reference to its primitive values, copying them.</p><p>That means that changes to the original array will not affect the copied array, which is what would happen if the array had been linked to the original with the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators">assignment operator</a> =:</p><p>The spread operator … is useful for working with arrays and objects in JavaScript. It is a convenient feature added in ES6 (ES2015).</p><p>I also like that it can quickly combine the properties of objects into a new object, though any properties whose names conflict will be lost.</p><p>Knowing the spread syntax definitely saves me time when coding, and I recommend using it to all JavaScript developers.</p><h4>Reference</h4><p><a href="https://www.udemy.com/course/the-complete-javascript-course/learn/lecture/22648535#content">https://www.udemy.com/course/the-complete-javascript-course</a></p><ul><li><a href="https://www.geeksforgeeks.org/javascript-rest-operator/">JavaScript | Rest parameter - GeeksforGeeks</a></li><li><a href="https://codeburst.io/javascript-es6-the-spread-syntax-f5c35525f754">JavaScript ES6— The Spread Syntax (…)</a></li><li><a href="https://medium.com/coding-at-dawn/how-to-use-the-spread-operator-in-javascript-b9e4a8b06fab">How to use the spread operator (…) in JavaScript</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0fe6f0f8a02" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>