<?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: Dita Larasati</title>
    <description>The latest articles on DEV Community by Dita Larasati (@ditaisy).</description>
    <link>https://dev.to/ditaisy</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%2F656196%2Fa1ac7d26-1574-4b4b-8ad0-a2cd6b443176.png</url>
      <title>DEV Community: Dita Larasati</title>
      <link>https://dev.to/ditaisy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ditaisy"/>
    <language>en</language>
    <item>
      <title>Encode, Encrypt, and Hash</title>
      <dc:creator>Dita Larasati</dc:creator>
      <pubDate>Sun, 27 Nov 2022 15:49:19 +0000</pubDate>
      <link>https://dev.to/ditaisy/encode-encrypt-and-hash-8de</link>
      <guid>https://dev.to/ditaisy/encode-encrypt-and-hash-8de</guid>
      <description>&lt;p&gt;In general, the meaning of &lt;strong&gt;encode is to convert something into code, something into a different format&lt;/strong&gt;. We usually do kind of encode for Personal Identifiable Information (PII) because it contains confidential data such as password, card number, etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  Encoding
&lt;/h2&gt;

&lt;p&gt;Simply said, encoding process happens as transforming a number from base 10 (decimal) into base 2 (binary) format. Usually, the algorithms used is in the form of rigid pattern such as conversion table of ASCII, Unicode, Base-64, and URL-encoding.&lt;/p&gt;

&lt;p&gt;Encoding technique is reversible. Anyone who knows the algorithm could decode the encoded data in order to retrieve the original data. &lt;/p&gt;

&lt;h2&gt;
  
  
  Encryption
&lt;/h2&gt;

&lt;p&gt;Similar to encoding, encryption technique is reversible but more secure. &lt;strong&gt;Encryption can protect data from unauthorized person&lt;/strong&gt;. A key is also needed to encrypt and decrypt the data, not only the algorithm.&lt;/p&gt;

&lt;p&gt;This key-based encryption algorithms is classified into &lt;strong&gt;symmetric-key algorithm&lt;/strong&gt; and &lt;strong&gt;asymmetric-key algorithm&lt;/strong&gt;. As the naming, the symmetric means that the key for encryption and decryption is equal, and the asymmetric is different. In asymmetric algorithm, public key is a name for the key to encrypt and private key is for to decrypt.&lt;/p&gt;

&lt;p&gt;Below is an example functions to do encryption-decryption:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcosci1ptgnae96q742ug.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcosci1ptgnae96q742ug.png" alt="Image description" width="704" height="441"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Hashing
&lt;/h2&gt;

&lt;p&gt;On the other hand, hashing can not do that kind of decode. &lt;strong&gt;Hashing is irreversible and more secure than encryption&lt;/strong&gt;. Once you hash something, you can not know what the "something" really is. Even though it literally hashes your data, I would say that you still could know what kind of thing the "something". Just imagine a criminal scene: you got potential suspects and blood of suspect in the crime scene. Here, the blood is the result of hash the potential suspect. By comparing the DNAs, we could know that the blood comes from the suspect.&lt;/p&gt;

&lt;p&gt;Hashing usually is implemented for password. Although programmer who creates the program, &lt;strong&gt;programmer is not allowed to know user's password&lt;/strong&gt;. A program must be designed to save user's password in the form of hashed password in database. None of way to decode it. &lt;/p&gt;

&lt;p&gt;The following is &lt;strong&gt;example of hashing-comparing implementation&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F551w9jk0cn7klp4vmlys.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F551w9jk0cn7klp4vmlys.png" alt="hashing" width="731" height="147"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpyfjusvahnllouyf726o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpyfjusvahnllouyf726o.png" alt="comparing" width="694" height="115"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;References:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://auth0.com/blog/hashing-passwords-one-way-road-to-security/" rel="noopener noreferrer"&gt;https://auth0.com/blog/hashing-passwords-one-way-road-to-security/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://auth0.com/blog/encoding-encryption-hashing/" rel="noopener noreferrer"&gt;https://auth0.com/blog/encoding-encryption-hashing/&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>watercooler</category>
      <category>discuss</category>
      <category>vscode</category>
    </item>
    <item>
      <title>What exactly the Agile is</title>
      <dc:creator>Dita Larasati</dc:creator>
      <pubDate>Sun, 21 Aug 2022 07:09:00 +0000</pubDate>
      <link>https://dev.to/ditaisy/what-exactly-the-agile-is-4gk5</link>
      <guid>https://dev.to/ditaisy/what-exactly-the-agile-is-4gk5</guid>
      <description>&lt;p&gt;In Software Development Life Cycle (SDLC), there are 6 main steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Planning&lt;/li&gt;
&lt;li&gt;Analysis &amp;amp; defining requirements&lt;/li&gt;
&lt;li&gt;Design&lt;/li&gt;
&lt;li&gt;Implementation or development&lt;/li&gt;
&lt;li&gt;Testing, and&lt;/li&gt;
&lt;li&gt;Operation &amp;amp; maintenance&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It is a life cycle then it must be always &lt;strong&gt;cyclic&lt;/strong&gt;, otherwise the product is stopped.&lt;/p&gt;

&lt;p&gt;The Agile is a principle that the end-user is a precedence thing in software development. Due to it tends &lt;strong&gt;customer-oriented&lt;/strong&gt;, people pursue to be &lt;strong&gt;agile over the changes, communicative, and critical&lt;/strong&gt;. There are so many ways or methods to approach the Agile such as Scrum, Kanban, or &lt;em&gt;you even could create yours – depends on your situations&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Hnit1nJG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1w9fr4p2ns8yqtwkr6gu.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Hnit1nJG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1w9fr4p2ns8yqtwkr6gu.jpg" alt="waterfall vs agile" width="744" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If the Waterfall runs linear from planning until maintenance which means it cannot go to the previous step. On the other hand, &lt;strong&gt;the Agile could revisit the previous step before continuing the next step&lt;/strong&gt;. It could be happened because every person could give feedback on the task. In addition, every process must be under customer agreement or confirmation. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;People in the team actively collaborate in cross functionality. At the end of the day, the product results end up with minimum risks.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Scrum is highly prescriptive&lt;/strong&gt;, everything is estimated/decided in advance. A Scrum Master is needed to ensure all things are going on the track. A product is delivered in a few smaller parts in a sprint planning meeting. It followed by sprint review, retrospective, and daily sprint (standup) meetings. Usually, &lt;strong&gt;a sprint takes 2 up to 4 weeks&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The Scrum practice usually implemented by large startups or corporates that have mature technology ecosystem. I think the big size of application is the main reason. It needs great workflow and large composition team in order to make product development securely efficiently effective.&lt;/p&gt;

&lt;p&gt;On the other hand, &lt;strong&gt;the Kanban method has concern about priority&lt;/strong&gt;. It suits for the team has many backlog product to develop whereas has low quality and/or quantity of team member. Nonetheless, Kanban doesn't pursue the team to set the timeline. There is no such a "Scrum Master" who manage everything on the rail. &lt;strong&gt;It really depends on collective collaboration and team commitment&lt;/strong&gt;. Unlike the Scrum, if the product finishes faster than the expectation, it could go to production as soon as possible. Again, because &lt;strong&gt;Kanban has no definite schedule&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A little addition, &lt;strong&gt;CI/CD pipeline implementation in the Agile SDLC would be very helpful&lt;/strong&gt;. Whenever a feature ready to be integrated, it immediately could be delivered and deployed to the production, or any environment you want.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;References:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://www.northeastern.edu"&gt;https://www.northeastern.edu&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.atlassian.com"&gt;https://www.atlassian.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://customerthink.com"&gt;https://customerthink.com&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>agile</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>Shell and REPL</title>
      <dc:creator>Dita Larasati</dc:creator>
      <pubDate>Sun, 24 Jul 2022 18:10:00 +0000</pubDate>
      <link>https://dev.to/ditaisy/shell-and-repl-34pi</link>
      <guid>https://dev.to/ditaisy/shell-and-repl-34pi</guid>
      <description>&lt;p&gt;A &lt;strong&gt;shell&lt;/strong&gt; is a command-line interpreter that &lt;strong&gt;interprets&lt;/strong&gt; what user enters in the command-line interface (CLI). And the CLI per se is a computer program for users to interact with computers with text-based UI.&lt;/p&gt;

&lt;p&gt;A computer with &lt;a href="https://en.wikipedia.org/wiki/Unix-like"&gt;Unix-like&lt;/a&gt; OS such as Linux, usually uses Unix-shell e.g. Bourne Again SHell (bash), TENEX C shell (tcsh), the Korn shell (ksh), the Z shell (zsh), etc. &lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;CLI implements&lt;/strong&gt; read, evaluate, print, and loop (&lt;strong&gt;REPL&lt;/strong&gt;) to make the interface interactive. It will loop until there is a condition that makes the process: read, evaluate, and print terminate.&lt;/p&gt;

&lt;p&gt;However, those are some programming languages that have their own shell e.g. Python, Java, Clojure, NodeJS, etc. In Java, we will use java shell (JShell) in our CLI in order to interpret java syntax entered. In general, people call a CLI that uses JShell as Java REPL, it goes the same for other languages. &lt;/p&gt;

&lt;p&gt;Actually, I am still figuring out the main purpose of a programming language REPL. We usually use IDE to develop a program with necessary, helpful, and important features inside. Presumably, because it only executes a unit of code, so it will be helpful to test atomically through REPL instead of running the program entirely. Honestly, I prefer to use &lt;a href="https://replit.com/"&gt;replit.com&lt;/a&gt; for that case.&lt;/p&gt;

&lt;p&gt;Popped in my head, if you inspect your browser and go to the console tab, it uses JavaScript. Yeah, I think that’s the best approach for a programming language REPL appearance.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>Asynchronous</title>
      <dc:creator>Dita Larasati</dc:creator>
      <pubDate>Fri, 08 Jul 2022 18:17:00 +0000</pubDate>
      <link>https://dev.to/ditaisy/asynchronous-and-callback-4gek</link>
      <guid>https://dev.to/ditaisy/asynchronous-and-callback-4gek</guid>
      <description>&lt;p&gt;Lately, I forgot what's the reason of &lt;code&gt;async&lt;/code&gt;/&lt;code&gt;await&lt;/code&gt; existence. Why do we have to use these keywords? What is promise? What is asynchronous? Also, what is callback? Here, I write it all about down as my personal note.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Synchronous code is executed line by line&lt;/strong&gt;. Each line of code waits for the previous line to finish. What if we have long-running operations block code execution? It might be cause blocking and unresponsive.&lt;/p&gt;

&lt;p&gt;Thus, asynchronous exists to solve this problem! &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Asynchronous code is executed after a task that runs in the background finishes.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To implement asynchronous code, we could use &lt;em&gt;callback functions&lt;/em&gt; and &lt;em&gt;promises&lt;/em&gt;. A &lt;strong&gt;callback function&lt;/strong&gt; is a function that passed as an argument to another function whereas &lt;strong&gt;promise&lt;/strong&gt; is something that is achieved or completed in the future. &lt;/p&gt;

&lt;p&gt;By using callback function we don’t need to assign the result of an operation into a variable then check if its error or not, simply just invoke the callback function at that time.&lt;/p&gt;

&lt;p&gt;Let us see the example codes below:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhkrbpib60yt1ljfhlrhc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhkrbpib60yt1ljfhlrhc.png" alt="controller"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fimdz5wvif525y1prh8fo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fimdz5wvif525y1prh8fo.png" alt="model"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we see, there are two asynchronous callback-based methods. The first is &lt;code&gt;Model.getPokemons()&lt;/code&gt; and the second is &lt;code&gt;pool.query()&lt;/code&gt; which is 3rd party API. &lt;/p&gt;

&lt;p&gt;To get pokemon list from the database, &lt;code&gt;Model.getPokemons()&lt;/code&gt; requires a callback function – conventionally written as &lt;code&gt;cb()&lt;/code&gt; – that must be provided by the &lt;code&gt;Controller.getPokemons()&lt;/code&gt;. Once the data fetching by &lt;code&gt;pool.query()&lt;/code&gt; is failed then returns the error, the model could immediately call the function &lt;code&gt;cb()&lt;/code&gt; by passing the error back to the controller. Then, the error could be forwarded to the client side. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;cb()&lt;/code&gt; as if an event handler. It's like "Hey, Model! Here, I provide the &lt;code&gt;cb()&lt;/code&gt;, just call it whenever you need – as you get the error or as the data is ready,"&lt;/p&gt;

&lt;p&gt;After successfully got the pokemon list, what if we need to fetch another data inside the else block? There will be so many nested callback, will make a &lt;strong&gt;callback hell&lt;/strong&gt; or &lt;strong&gt;pyramid of doom&lt;/strong&gt;. That's painful code causes maintenance and reading the code hard and must handle the error repetitively – did in every nest. Those are the reason why most modern asynchronous APIs don't use callbacks anymore.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Need to know&lt;/strong&gt;:&lt;br&gt;
A callback function doesn't automatically make code asynchronous. For instance, built-in functions in JavaScript that require a callback function. Usually, an asynchronous callback-based code has this format &lt;code&gt;(err, value) =&amp;gt; {}&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffjhjtnxkz7elbxmibuz1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffjhjtnxkz7elbxmibuz1.png" alt="built-in fn js"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Callback-based API: &lt;br&gt;
&lt;code&gt;setTimeout(cb, number)&lt;/code&gt;, &lt;br&gt;
&lt;code&gt;addEventListener(string, cb)&lt;/code&gt;, &lt;em&gt;from &lt;code&gt;XMLHttpRequest()&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Promise-based API:&lt;br&gt;
&lt;code&gt;fetch()&lt;/code&gt;, &lt;em&gt;modern version of &lt;code&gt;XMLHttpRequest()&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Promise (ES6)
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frns4uz76wqd6x959osj5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frns4uz76wqd6x959osj5.png" alt="promise schenario"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Promise – the foundation of asynchronous programming in JavaScript – is an object and we use the promise constructor to initialize a promise.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2t7mty5z0g9bbhnomzb0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2t7mty5z0g9bbhnomzb0.png" alt="promise basic example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are some instance methods of promise to handle the eventual success or failure of the operation:&lt;br&gt;
&lt;code&gt;.then()&lt;/code&gt; to handle the &lt;strong&gt;fulfilled&lt;/strong&gt; / successful&lt;br&gt;
&lt;code&gt;.catch()&lt;/code&gt; to handle the &lt;strong&gt;rejected&lt;/strong&gt; / failed&lt;br&gt;
&lt;code&gt;.finally()&lt;/code&gt; to handle the &lt;strong&gt;settled&lt;/strong&gt; (fulfilled or rejected)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;All those three are methods of promise that return a promise&lt;/strong&gt;. Allowing you to chain calls to another promise method, an operation called &lt;em&gt;composition&lt;/em&gt;. Also, &lt;strong&gt;with promise chaining, avoiding ever-increasing levels of indentation&lt;/strong&gt; when we need to make consecutive asynchronous function calls by using &lt;code&gt;.then()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If a promise doesn’t call &lt;code&gt;.then()&lt;/code&gt; or &lt;code&gt;.catch()&lt;/code&gt;, it will always be &lt;em&gt;pending&lt;/em&gt; because those two methods accept / forward the return of the promise operation and allow us to know its &lt;em&gt;settled status&lt;/em&gt;, whether is the promise operation successful or not.&lt;/p&gt;

&lt;p&gt;However, because a promise passes a callback function, promise could encounter callback-hell as well, named &lt;em&gt;promise-hell&lt;/em&gt;. It is caused of there is a new promise &lt;code&gt;.then()&lt;/code&gt; of top promise. It’s a condition where an asynchronous operation depends on the result of previous asynchronous operation. Otherwise, we can use &lt;code&gt;Promise.all()&lt;/code&gt;, &lt;code&gt;Promise.any()&lt;/code&gt;, etc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nice to know&lt;/strong&gt; &lt;br&gt;
Promisifying is a method from NodeJS to convert a callback-based to promise-based asynchronous function. &lt;code&gt;util.promisify(cb)&lt;/code&gt; taking an &lt;code&gt;(err, value) =&amp;gt; ...&lt;/code&gt; callback as the last argument, and returns a version that returns promises.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Async/await (ES8)&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;We are not only just using an asynchronous promise-based API from a 3rd party. Instead of using the old way style promise constructor, we can make our own by using &lt;code&gt;async&lt;/code&gt; keywords! &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Async/await is built on promises&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The &lt;code&gt;async&lt;/code&gt; keyword gives you a simpler way to work with asynchronous promise-based code. &lt;strong&gt;By adding &lt;code&gt;async&lt;/code&gt; at the start of a function makes it an asynchronous function&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Inside an &lt;code&gt;async&lt;/code&gt; function you can use the &lt;code&gt;await&lt;/code&gt;keyword before a promise-returning function. This makes the code wait at that point until the promise is settled, at which point the fulfilled value of the promise is treated as a return value, or the rejected value is thrown. Presumably, &lt;code&gt;await&lt;/code&gt; keyword behaves like &lt;code&gt;.then()&lt;/code&gt; and &lt;code&gt;.catch()&lt;/code&gt; at once!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;async function always return a promise&lt;br&gt;
only use await inside an async function&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;As seen code below, let's say we want to consume a promise-based 3rd party API named &lt;code&gt;checkOddNumber()&lt;/code&gt;. We can handle the promise by using &lt;code&gt;.then()&lt;/code&gt; &lt;code&gt;.catch()&lt;/code&gt; &lt;code&gt;.finally()&lt;/code&gt; or simply just using &lt;code&gt;async&lt;/code&gt; &lt;code&gt;await&lt;/code&gt; with &lt;code&gt;try...catch...finally&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7wqd9l6f9gfofjrzqlho.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7wqd9l6f9gfofjrzqlho.png" alt="promise-based api"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp0kq8ugzxil1i610smo3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp0kq8ugzxil1i610smo3.png" alt="handling promise"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Keep in mind that just like a promise chain, &lt;code&gt;await&lt;/code&gt; forces asynchronous operations to be completed in series – easier to express and &lt;strong&gt;there will be no more nested callback or callback hell&lt;/strong&gt;. This is necessary if the result of the next operation depends on the result of the last one. &lt;/p&gt;




&lt;p&gt;&lt;strong&gt;References:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Learn/JavaScript" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Learn/JavaScript&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://nodejs.dev/learn/modern-asynchronous-javascript-with-async-and-await" rel="noopener noreferrer"&gt;https://nodejs.dev/learn/modern-asynchronous-javascript-with-async-and-await&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://nodejs.org/api/util.html#utilpromisifyoriginal" rel="noopener noreferrer"&gt;https://nodejs.org/api/util.html#utilpromisifyoriginal&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://linuxhint.com/callback-promise-javascript-examples" rel="noopener noreferrer"&gt;https://linuxhint.com/callback-promise-javascript-examples&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>programming</category>
      <category>node</category>
      <category>javascript</category>
      <category>asynchronous</category>
    </item>
    <item>
      <title>Mutable and Immutable</title>
      <dc:creator>Dita Larasati</dc:creator>
      <pubDate>Sun, 26 Jun 2022 16:22:00 +0000</pubDate>
      <link>https://dev.to/ditaisy/what-is-mutable-in-javascript--52gf</link>
      <guid>https://dev.to/ditaisy/what-is-mutable-in-javascript--52gf</guid>
      <description>&lt;p&gt;Honestly, this article is my old personal note as I was in programming bootcamp. Why do I end up to bring this to you? My colleague said that &lt;code&gt;.forEach()&lt;/code&gt; will mutate the array but &lt;code&gt;.map()&lt;/code&gt; won't. Hm. It is true but it is not so true..&lt;/p&gt;

&lt;p&gt;In JavaScript, there are primitive and non-primitive value. As &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Primitive"&gt;MDN&lt;/a&gt; said, &lt;strong&gt;primitive value is data that is not an object and has no methods or properties&lt;/strong&gt; such as string, number, bigint, boolean, undefined, symbol, and null.&lt;/p&gt;

&lt;p&gt;Thus, the rest will be categorized as non-primitive (Objects). For example, Object literal, Array, Set, Map, Function, and even Class &amp;amp; Instance because it could has a method/property.&lt;/p&gt;

&lt;p&gt;Let us see to the example code below:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BfIoxKWB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g6psrbnyc5sj8g069mq7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BfIoxKWB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g6psrbnyc5sj8g069mq7.png" alt="Immutable" width="529" height="178"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--te-EJqsV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tn0jlx1kpj0b0ag3ukgk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--te-EJqsV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tn0jlx1kpj0b0ag3ukgk.png" alt="Mutable" width="531" height="254"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;What actually happened to the primitives are &lt;strong&gt;the original value can not be altered&lt;/strong&gt;. The original value still exist in memory and can be accessed as long as its variable not be assigned to another value.&lt;/p&gt;

&lt;p&gt;The opposite thing happens to &lt;strong&gt;objects literal, array, and function&lt;/strong&gt;. With those data types, the variable &lt;strong&gt;will refer to the same address where the original value at&lt;/strong&gt;. That's why it is named &lt;strong&gt;Referenced-type Objects&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;So, please be careful with referenced-type objects because you could not access the original value once the its variable has been passed into another variable and then computed.&lt;/p&gt;

&lt;p&gt;The conclusion is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Primitives are passing their value but non-primitives are passing their value's address.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In addition, &lt;strong&gt;referenced-type objects are always mutable even tho they are declared as &lt;code&gt;const&lt;/code&gt;&lt;/strong&gt;. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rvlT3GYC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d5liu489yrrdmo9wijtc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rvlT3GYC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d5liu489yrrdmo9wijtc.png" alt="const is not relevant" width="531" height="196"&gt;&lt;/a&gt; &lt;br&gt;
Important thing to remember, variable declaration, &lt;code&gt;const&lt;/code&gt;and &lt;code&gt;let&lt;/code&gt;merely are about re-assign-ability the variable name. Presumably, a keyword to help programmer to be consistent and attentive during development.&lt;/p&gt;

&lt;p&gt;Many people I know tends to use &lt;code&gt;let&lt;/code&gt; if they would like to change the element of array or property of object in the next line. But I never do that because that's not how the &lt;code&gt;let&lt;/code&gt; aimed for. You just change the inside or the part of the value, not the entire value.&lt;/p&gt;

&lt;p&gt;For the last!&lt;br&gt;
About &lt;code&gt;.forEach()&lt;/code&gt; and &lt;code&gt;.map()&lt;/code&gt; as I was mentioned above&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Tyi_qk6e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ljxctddf6mcxohs6pzkm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Tyi_qk6e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ljxctddf6mcxohs6pzkm.png" alt=".forEach() and .map() is not relevant" width="529" height="223"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;.forEach()&lt;/code&gt; and &lt;code&gt;.map()&lt;/code&gt; methods have different purpose. &lt;code&gt;.forEach()&lt;/code&gt; is void method, it is just do the looping. &lt;code&gt;.map()&lt;/code&gt; is non-void method, it creates a new array from which the elements got from the result iteration of the calling array.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>immutable</category>
      <category>programming</category>
      <category>node</category>
    </item>
  </channel>
</rss>
