<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: frk-ozbk</title>
    <description>The latest articles on DEV Community by frk-ozbk (@frk_ozbk).</description>
    <link>https://dev.to/frk_ozbk</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F313658%2F6bbcca80-d2c4-475d-862a-00938c83274a.png</url>
      <title>DEV Community: frk-ozbk</title>
      <link>https://dev.to/frk_ozbk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/frk_ozbk"/>
    <language>en</language>
    <item>
      <title>Javascript Closure</title>
      <dc:creator>frk-ozbk</dc:creator>
      <pubDate>Thu, 12 Mar 2020 07:29:13 +0000</pubDate>
      <link>https://dev.to/frk_ozbk/javascript-closure-4pk2</link>
      <guid>https://dev.to/frk_ozbk/javascript-closure-4pk2</guid>
      <description>&lt;p&gt;In javascript, when a function returns another function, a function that returned can access the variables inside the other function. This is called &lt;strong&gt;closure&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;counter&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;consoleIt&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="k"&gt;debugger&lt;/span&gt;
    &lt;span class="nx"&gt;number&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In this example inside the &lt;strong&gt;counter&lt;/strong&gt; function there is a variable named &lt;strong&gt;number&lt;/strong&gt; and this function returns another function. We invoke the &lt;strong&gt;counter&lt;/strong&gt; function and assigned consoleIt function to  the &lt;strong&gt;increment&lt;/strong&gt; variable.But there is one more thing. Now consoleIt function can access the &lt;strong&gt;number&lt;/strong&gt; variable. You can see this if you put &lt;em&gt;debugger&lt;/em&gt; inside the consoleIt function.&lt;br&gt;
Whenever we invoke &lt;strong&gt;increment&lt;/strong&gt; function, &lt;strong&gt;number&lt;/strong&gt; variable will be increased by one.&lt;/p&gt;
&lt;h2&gt;
  
  
  What is the benefit of &lt;strong&gt;closure&lt;/strong&gt;?
&lt;/h2&gt;

&lt;p&gt;You can give memory to functions. Whenever function invoked, it can remember variables from past invokes.&lt;br&gt;
For example;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;debounce&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;debounceFn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;timeoutId&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(...&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="nx"&gt;clearTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;timeoutId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;timeoutId&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nx"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;debounceFn&lt;/span&gt;&lt;span class="p"&gt;(...&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="nx"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;debouncedHandleSearch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;debounce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;handleSearch&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Whenever we invoke &lt;strong&gt;debouncedHandleSearch&lt;/strong&gt; function, it will remember timeoutID and clear it.&lt;/p&gt;

&lt;p&gt;Thanks for reading it. You can see my other post below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/frk_ozbk/understanding-this-3k67"&gt;Understanding This&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/frk_ozbk/what-is-the-difference-between-var-and-let-436a"&gt;What is the difference between var and let&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/frk_ozbk/what-is-syntactic-sugar-5d5g"&gt;What is syntactic sugar&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Understanding "This"</title>
      <dc:creator>frk-ozbk</dc:creator>
      <pubDate>Mon, 02 Mar 2020 07:02:37 +0000</pubDate>
      <link>https://dev.to/frk_ozbk/understanding-this-3k67</link>
      <guid>https://dev.to/frk_ozbk/understanding-this-3k67</guid>
      <description>&lt;p&gt;&lt;strong&gt;This&lt;/strong&gt; keyword is a little bit tricky. In javascript, &lt;strong&gt;this&lt;/strong&gt; keyword refers to an object that executing function.&lt;/p&gt;

&lt;p&gt;By default, there is only &lt;strong&gt;Global Object&lt;/strong&gt;. So if you declare a function that logs the &lt;b&gt;This&lt;/b&gt; and invoke it, it will log the Global Object.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.imageupload.net/image/LAfeg"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PPDv_xXn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imagehost.imageupload.net/2020/02/27/global.png" alt="global.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But things change when you declare an object and invoke the function from that object.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.imageupload.net/image/LAHL8"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zO-_z5E_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imagehost.imageupload.net/2020/02/27/object-this5bc9f567b45e6383.md.png" alt="object-this5bc9f567b45e6383.md.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Why did the function log the person object?
&lt;/h3&gt;

&lt;p&gt;Because the object that executes or invokes the "consoleThis" function changed. Now the &lt;strong&gt;person&lt;/strong&gt; object execute the function.So &lt;strong&gt;this&lt;/strong&gt; keyword refers to &lt;strong&gt;person&lt;/strong&gt; object.&lt;/p&gt;

&lt;h3&gt;
  
  
  So what are the benefits of &lt;em&gt;this&lt;/em&gt; keyword?
&lt;/h3&gt;

&lt;p&gt;Well, you can create reusable functions. What does that mean?&lt;br&gt;
Let's look at the example.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.imageupload.net/image/LLECZ"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HAHQRmnC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imagehost.imageupload.net/2020/02/27/reusable.md.png" alt="reusable.md.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We declared two objects: &lt;strong&gt;personA&lt;/strong&gt; and &lt;strong&gt;personB&lt;/strong&gt;&lt;br&gt;
These objects have three keys: &lt;em&gt;name&lt;/em&gt;, &lt;em&gt;key&lt;/em&gt; and increaseAgeBy function.We invoke &lt;em&gt;increaseAgeBy(1)&lt;/em&gt; on &lt;strong&gt;personA&lt;/strong&gt; object.Inside the &lt;em&gt;increaseAgeBy&lt;/em&gt; function &lt;strong&gt;this&lt;/strong&gt; will refer to personA object. &lt;br&gt;
&lt;em&gt;personA.age&lt;/em&gt; was 22 so now personA's age is 22 + 1 = 23.&lt;br&gt;
Then we invoke &lt;em&gt;increaseAgeBy(10)&lt;/em&gt; on &lt;strong&gt;personB&lt;/strong&gt; object.Now &lt;strong&gt;this&lt;/strong&gt; will refer personB object.personB.age is 18 so now personB's age was 18 +10 = 28.&lt;/p&gt;

&lt;h3&gt;
  
  
  What if I do this?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.imageupload.net/image/ZlQfs"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EPk9hAqK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imagehost.imageupload.net/2020/03/03/LogIt.png" alt="LogIt.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We declare the same &lt;strong&gt;person&lt;/strong&gt; object. Then we declare the logIt variable outside the object then assign the &lt;strong&gt;logName&lt;/strong&gt; function inside the personA object. But when we invoke it, we don't invoke logIt function from &lt;strong&gt;personA&lt;/strong&gt; object, we invoke from the global object so &lt;strong&gt;this&lt;/strong&gt; keyword will refer global object. There is no variable named "name" inside the global object so the function will log "undefined".&lt;/p&gt;

&lt;h3&gt;
  
  
  Apply, Bind and Call Function Methods
&lt;/h3&gt;

&lt;p&gt;Call and Apply methods work similarly. Both invoke the function they called and their first parameter is that Object that you want to bind &lt;strong&gt;this&lt;/strong&gt;. The difference is that &lt;strong&gt;Apply&lt;/strong&gt; takes arguments as an array; &lt;strong&gt;Call&lt;/strong&gt; requires the parameters to be listed explicitly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.imageupload.net/image/ZlTyd"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pLIbLmBg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imagehost.imageupload.net/2020/03/03/apply.png" alt="apply.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.imageupload.net/image/ZleL8"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WrGUQTBX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imagehost.imageupload.net/2020/03/03/call.md.png" alt="call.md.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Bind works differently. It creates a new function when called, has its &lt;strong&gt;this&lt;/strong&gt; keyword set to first parameter.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.imageupload.net/image/Zl3tx"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wFEAeIdY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imagehost.imageupload.net/2020/03/03/sayMyName.png" alt="sayMyName.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Why did not &lt;em&gt;sayPersonAName&lt;/em&gt; function return 'Lucy' instead of 'Jack'? &lt;br&gt;
 Because we bound &lt;em&gt;sayMyName&lt;/em&gt; function to PersonA object. This created a new function that has it's &lt;em&gt;this&lt;/em&gt; keyword set to PersonA. So whenever we call this function its &lt;strong&gt;this&lt;/strong&gt; will refer to PersonA object.&lt;/p&gt;

&lt;p&gt;Thank you for reading. See my other posts below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/frk_ozbk/what-is-the-difference-between-var-and-let-436a"&gt;What is the difference between var and let&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/frk_ozbk/what-is-syntactic-sugar-5d5g"&gt;What is syntactic sugar&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>What is the difference between 'Var' and 'Let' ?</title>
      <dc:creator>frk-ozbk</dc:creator>
      <pubDate>Wed, 26 Feb 2020 07:41:52 +0000</pubDate>
      <link>https://dev.to/frk_ozbk/what-is-the-difference-between-var-and-let-436a</link>
      <guid>https://dev.to/frk_ozbk/what-is-the-difference-between-var-and-let-436a</guid>
      <description>&lt;p&gt;First of all, I want to talk about &lt;em&gt;Javascript Scopes&lt;/em&gt;.&lt;br&gt;
Scopes determine the accessibility of the variable. You can't access a variable from outside of its scope.&lt;/p&gt;

&lt;p&gt;In Javascript, before ES6 there were two types of scope:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Global Scope&lt;/li&gt;
&lt;li&gt;Local Scope (Function Scope)&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Global Scope
&lt;/h2&gt;

&lt;p&gt;Any variable declared outside of a block or function is inside &lt;em&gt;Global Scope&lt;/em&gt;.You can access these variables from everywhere.&lt;/p&gt;




&lt;h2&gt;
  
  
  Local Scope (Function Scope)
&lt;/h2&gt;

&lt;p&gt;As the name suggests, variables declared inside the Function has Local Scope. They can only be accessed inside the Function.&lt;/p&gt;




&lt;p&gt;ES6 introduces &lt;strong&gt;Let&lt;/strong&gt; and &lt;strong&gt;Const&lt;/strong&gt; variables that can be scoped to a block. So now there is one more type of scope.&lt;/p&gt;

&lt;h2&gt;
  
  
  Block Scope
&lt;/h2&gt;

&lt;p&gt;In Javascript curly brackets creates a block. So if you declare a variable inside the block with &lt;strong&gt;Let&lt;/strong&gt; or &lt;strong&gt;Const&lt;/strong&gt;, you can't access it from outside of that block.&lt;/p&gt;




&lt;h1&gt;
  
  
  Var
&lt;/h1&gt;

&lt;p&gt;Variables declared with &lt;strong&gt;Var&lt;/strong&gt; has function scope. You can't access this variable from outside the function. However, if you declare variables inside the block with &lt;strong&gt;Var&lt;/strong&gt; you can access it from outside.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.imageupload.net/image/L6dTB"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xT12PONR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imagehost.imageupload.net/2020/02/26/block.png" alt="block.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Unlike &lt;strong&gt;Var&lt;/strong&gt;, &lt;strong&gt;Let&lt;/strong&gt; has block scope. You can only access these variables from inside the block. So if you try to access from outside it will give you &lt;em&gt;Reference Error&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.imageupload.net/image/L6HRs"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PbxrCD1K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imagehost.imageupload.net/2020/02/26/let-block.png" alt="let-block.png"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;You can reassign the variable that declared with &lt;strong&gt;Var&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.imageupload.net/image/L6nVK"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XDQDcr6Z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imagehost.imageupload.net/2020/02/26/var-reassign.png" alt="var-reassign.png"&gt;&lt;/a&gt;&lt;br&gt;
But you can't with &lt;strong&gt;Let&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.imageupload.net/image/L64NM"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2K-XuIhG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imagehost.imageupload.net/2020/02/26/let-reassign.png" alt="let-reassign.png"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Var declarations (&lt;code&gt;var a&lt;/code&gt;) whenever they occur, they move up to the top of the file. This is called &lt;code&gt;hoisting&lt;/code&gt;.With this, you can do something like this. (You can read more about &lt;code&gt;hoisting&lt;/code&gt; if you click &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Hoisting"&gt;here&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.imageupload.net/image/LMGyv"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--o8KxPwB4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imagehost.imageupload.net/2020/02/26/var-hoisting.png" alt="var-hoisting.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With &lt;strong&gt;let&lt;/strong&gt; you can't do this. It will give an error:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.imageupload.net/image/LMgla"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--be0YvFxd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imagehost.imageupload.net/2020/02/26/let-hoisting.png" alt="let-hoisting.png"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Reference
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/"&gt;https://developer.mozilla.org/en-US/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>What is Syntactic Sugar</title>
      <dc:creator>frk-ozbk</dc:creator>
      <pubDate>Fri, 10 Jan 2020 19:49:27 +0000</pubDate>
      <link>https://dev.to/frk_ozbk/what-is-syntactic-sugar-5d5g</link>
      <guid>https://dev.to/frk_ozbk/what-is-syntactic-sugar-5d5g</guid>
      <description>&lt;p&gt;Today I wanted to talk about syntactic sugar and how it improves you and your team coding life.&lt;/p&gt;

&lt;p&gt;In computer science, &lt;strong&gt;syntactic sugar&lt;/strong&gt; is syntax within a programming language that is designed to make things easier to read or to express.&lt;/p&gt;

&lt;p&gt;Let's look at this example. I have an array of items. And I want to check every item is selected or not?&lt;/p&gt;

&lt;h5&gt;
  
  
  Classic Javascript Loop
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://ibb.co/nnMQWDR" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.ibb.co%2FqWYmZRx%2Fexample-1.png" alt="example-1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Javascript array method - .every()
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://ibb.co/g38DfTz" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.ibb.co%2FvHWJTPZ%2Fexample-3.png" alt="example-1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Which one do you prefer using? I think &lt;strong&gt;.every()&lt;/strong&gt; is cleaner and it explains itself.&lt;/p&gt;

&lt;p&gt;Let's look at example two. This time I want to select all items if all items are not selected. If all items are selected, I want to remove all items.&lt;/p&gt;

&lt;h5&gt;
  
  
  Classic Javascript Loop
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://ibb.co/4Vyj3H2" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.ibb.co%2FRDnCdqN%2Fexample-4.png" alt="example-2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Javascript array method - .forEach()
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://ibb.co/prV2GH8" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.ibb.co%2F93KnzxL%2Fexample-5.png" alt="example-2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is not shorter too much. But still, it is shorter and it is self-explanatory.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusions
&lt;/h1&gt;

&lt;p&gt;Syntactic sugar improves your coding life. Believe me every line matters.&lt;br&gt;
If you are using React or Vue you will have many methods and JSX or Templates in a single component. That is for this post.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>cleancode</category>
      <category>syntacticsugar</category>
    </item>
  </channel>
</rss>
