<?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>Forem: casiimir</title>
    <description>The latest articles on Forem by casiimir (@casiimir).</description>
    <link>https://forem.com/casiimir</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%2F475590%2F15513304-fbc6-4bd5-bf1e-60b4e5d54cbd.jpeg</url>
      <title>Forem: casiimir</title>
      <link>https://forem.com/casiimir</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/casiimir"/>
    <language>en</language>
    <item>
      <title>Less 3 Than - The Heming(way) approach to buy game keys</title>
      <dc:creator>casiimir</dc:creator>
      <pubDate>Wed, 03 Mar 2021 07:40:56 +0000</pubDate>
      <link>https://forem.com/casiimir/less-3-than-the-heming-way-approach-to-buy-game-keys-3ddh</link>
      <guid>https://forem.com/casiimir/less-3-than-the-heming-way-approach-to-buy-game-keys-3ddh</guid>
      <description>&lt;h2&gt;
  
  
  How to find the best and cheapest game keys from internet
&lt;/h2&gt;

&lt;h3&gt;
  
  
  For whom code types ⌨️, and gamers! 🎮
&lt;/h3&gt;

&lt;p&gt;My dear friends, this is &lt;em&gt;Casiimir&lt;/em&gt; speaking. I have spent too many days on this. They have gone by so fast, but now &lt;strong&gt;the time is due&lt;/strong&gt;! I therefore welcome the opportunity to present my final project during the &lt;strong&gt;#AmplifyHashnode&lt;/strong&gt; hackathon!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The Heming(way) to solve any problem is&lt;/em&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Now is no time to think of what you do not have. Think of what you can do with what there is."&lt;/p&gt;

&lt;p&gt;The Old Man and the Sea&lt;/p&gt;
&lt;/blockquote&gt;



&lt;h2&gt;
  
  
  What's this?
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Less3️⃣Than
&lt;/h3&gt;

&lt;p&gt;Less 3 Than is a very useful web app that's basically what all gamers want! &lt;strong&gt;It makes it possibile to find the lowest price available&lt;/strong&gt; for any video game (only PC/Mac), by &lt;em&gt;comparing more than 25 stores&lt;/em&gt; and &lt;em&gt;it gives you which game is under 3$&lt;/em&gt;!&lt;/p&gt;

&lt;p&gt;The web app takes the gamer by the hand and guides him towards the lists of the cheapest and top rated games, the stores and the link where to buy them. Everything with common interface, minimal and clear design.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The most incredibile thing to ever happen in other website is the presence of free games too!!&lt;/p&gt;
&lt;/blockquote&gt;



&lt;h2&gt;
  
  
  Usefulness: the beating heart of an idea
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Monday - concept of necessity 🌱
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;My friend&lt;/strong&gt;: hey Casiimir!, are there any free game this week?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Me&lt;/strong&gt; (&lt;em&gt;thinking&lt;/em&gt;): have you tried just Googling "free pc games this week"?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Me&lt;/strong&gt; (&lt;em&gt;answer&lt;/em&gt;): let's keep talking about this in a couple hours...
(five hours later)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Me&lt;/strong&gt;: hey! Check out this cool web-app (no css, no nothig!)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;My friend&lt;/strong&gt;: Woah! Today Epic Games has on RAGE 2 for free! Thank you man!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Me&lt;/strong&gt; (&lt;em&gt;thinking&lt;/em&gt;): maybe i could use React... maybe SASS too... just a little piece of code, nothing else...&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Tuesday - the dawn of a new app  🌅
&lt;/h3&gt;

&lt;p&gt;The project grew fast,  especially with the implementation of &lt;em&gt;React&lt;/em&gt;... I totally immersed myself in that, so much that I haven't got time to think. That night, 4 hours of &lt;em&gt;Figma *and 3 hours testing *CSS&lt;/em&gt;, I reach an accord on the &lt;em&gt;UI *and *UX *- **destined to change rapidly&lt;/em&gt;*. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iiy1-ngw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1614520324903/xIUX8bhWw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iiy1-ngw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1614520324903/xIUX8bhWw.jpeg" alt="first.jpeg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Wednesday - It's verse, verse, code ✒️
&lt;/h3&gt;

&lt;p&gt;The code traveled along the walls of my room, my fingers new **dependencies **of the keyboard, the whole room's **extension **of my computer. Time had a way of making a different journey in that place.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Time is what turns kittens into cats.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Thursday - Merlin, fetch my spells, please ✨
&lt;/h3&gt;

&lt;p&gt;Finally it works. The &lt;em&gt;magic of a Fetch&lt;/em&gt;, a &lt;em&gt;few lines of CSS&lt;/em&gt; and* the power of React's rendering*. The code is dirty and messy, and very smelly, fortunately there is no one around - but commits on Github, &lt;strong&gt;speak for themselves&lt;/strong&gt;...&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;First attempt:&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--o1YG8PTQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1614520368308/EJGAtqnhc.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--o1YG8PTQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1614520368308/EJGAtqnhc.jpeg" alt="preVer.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Friday - You need to put more pressure on the brush 🧹
&lt;/h3&gt;

&lt;p&gt;Now, what we want is a &lt;strong&gt;deep cleanse&lt;/strong&gt;. Turn all the &lt;em&gt;CSS&lt;/em&gt; into &lt;em&gt;SASS&lt;/em&gt; - you're probably wondering why I just didn't do that in the first place.&lt;/p&gt;

&lt;h3&gt;
  
  
  Saturday - To the end, and beyond that, if need be 🏁
&lt;/h3&gt;

&lt;p&gt;It is said that "&lt;em&gt;ideas are more powerful than guns&lt;/em&gt;". I've had it up to here.  I was overflowing with ideas, but &lt;strong&gt;now kittens are aged&lt;/strong&gt;, just one last day to the &lt;em&gt;Hackathon’s deadline&lt;/em&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Well, with the promise to add more stunning features I continued to cleaning the code.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Sunday - The result, finally! 🤩
&lt;/h3&gt;

&lt;p&gt;At this very moment I'm writing the article...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JAPM6yRs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1614520425372/_Q19hfweM.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JAPM6yRs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1614520425372/_Q19hfweM.jpeg" alt="1.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Features include ✔️
&lt;/h3&gt;

&lt;p&gt;These are all qualities which are to be appreciated:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A catalogue of the &lt;strong&gt;cheapest Top Rated game keys&lt;/strong&gt; (by comparing more than 25 stores)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mobile first&lt;/strong&gt;, optimized for user experience&lt;/li&gt;
&lt;li&gt;Intuitive and &lt;strong&gt;minimal view&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Faster and responsive&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Complete with the search option (&lt;strong&gt;searching for lower priced&lt;/strong&gt; too!)&lt;/li&gt;
&lt;li&gt;Open Source, under the &lt;strong&gt;MIT License&lt;/strong&gt;, available on Github&lt;/li&gt;
&lt;li&gt;More features &lt;em&gt;very soon&lt;/em&gt;!&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Mobile first: the philosophy 📱
&lt;/h3&gt;

&lt;p&gt;The web app was born in my Iphone 6S, piece after piece. &lt;em&gt;Smartphone are smart&lt;/em&gt;. Precisely because of its &lt;strong&gt;responsivity characteristics&lt;/strong&gt; and the quicker accessibility I decided to optimize the &lt;em&gt;Mobile version&lt;/em&gt;.&lt;br&gt;
But it works well in other device, &lt;em&gt;desktop too&lt;/em&gt;!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;But in the future I'll want to improve this aspect.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iaO6_sjy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1614521490843/N9GAI8w0I.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iaO6_sjy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1614521490843/N9GAI8w0I.jpeg" alt="medium.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The cradle of the app 🔧
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Sass&lt;/li&gt;
&lt;li&gt;React&lt;/li&gt;
&lt;li&gt;Figma&lt;/li&gt;
&lt;li&gt;AWS Amplify&lt;/li&gt;
&lt;li&gt;API from cheapshark.com (&lt;em&gt;thank you&lt;/em&gt;!)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Improvements to be made ⏳
&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;Sort by price&lt;/li&gt;
  &lt;li&gt;Select range of price, from - to&lt;/li&gt;
  &lt;li&gt;Dedicated sections for every game&lt;/li&gt;
  &lt;li&gt;Specific stores section&lt;/li&gt;
  &lt;li&gt;More interactivity for the user&lt;/li&gt;
  &lt;li&gt;Add more stores to compare&lt;/li&gt;
  &lt;li&gt;and much more...&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://main.dj9o4v3tesilx.amplifyapp.com/"&gt;Demo&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/casiimir/less-than-three"&gt;Repo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Thank you reader too&lt;/em&gt;, it's incredibly important for me that you are here with me!&lt;/p&gt;




&lt;h3&gt;
  
  
  Do you like my app? Would you support me? Please leave a like (in &lt;a href="https://casiimir.hashnode.dev/less-3-than-the-hemingway-approach-to-buy-game-keys"&gt;Hashnode&lt;/a&gt; too, if possibile) 🙏 Or &lt;a href="https://www.buymeacoffee.com/casiimir"&gt;buy me a coffee&lt;/a&gt; ☕
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.buymeacoffee.com/casiimir"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_k3r_vpZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1614510978627/Ph5pQupgq.jpeg" alt="img.buymeacoffee.jpg"&gt;&lt;/a&gt; &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>programming</category>
      <category>gamedev</category>
    </item>
    <item>
      <title>Router in plain JS</title>
      <dc:creator>casiimir</dc:creator>
      <pubDate>Sat, 09 Jan 2021 23:07:33 +0000</pubDate>
      <link>https://forem.com/casiimir/router-in-plain-js-4dl9</link>
      <guid>https://forem.com/casiimir/router-in-plain-js-4dl9</guid>
      <description>&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/casiimir/embed/VwKBdRb?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>router</category>
      <category>codenewbie</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Gallary, a minimal gallery with Grid</title>
      <dc:creator>casiimir</dc:creator>
      <pubDate>Mon, 04 Jan 2021 21:46:45 +0000</pubDate>
      <link>https://forem.com/casiimir/gallary-a-minimal-gallery-with-grid-3oe4</link>
      <guid>https://forem.com/casiimir/gallary-a-minimal-gallery-with-grid-3oe4</guid>
      <description>&lt;p&gt;Work in progress, every advice is essential.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/casiimir/embed/OJRvWZR?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>codepen</category>
    </item>
    <item>
      <title>Covid19 Italy - a project for my Country</title>
      <dc:creator>casiimir</dc:creator>
      <pubDate>Thu, 31 Dec 2020 09:46:10 +0000</pubDate>
      <link>https://forem.com/casiimir/covid19-italy-a-project-for-my-country-20ff</link>
      <guid>https://forem.com/casiimir/covid19-italy-a-project-for-my-country-20ff</guid>
      <description>&lt;p&gt;&lt;em&gt;In this year together, we have fought, and we keep doing that, a war. It might sound exaggerated, but think it over, about the effects: crisis in every field. Who suffer from it? The economies of the countries. Who suffers most often? The society, the human relation and, more than any other, every single man and woman who faced (and facing), with difficulty, this crisis.&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Let us not be discouraged, however, by the difficulties, &lt;strong&gt;together&lt;/strong&gt;, once again in the human history, we will rise. Renewed. &lt;strong&gt;Stronger and united&lt;/strong&gt;.&lt;br&gt;
This is the big lesson from this big crisis.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Sorry for this introduction. My project starts precisely from that.&lt;br&gt;
I wrote this that &lt;strong&gt;takes the data&lt;/strong&gt; from Italy official dataset (&lt;em&gt;protezione civile, whom I thank&lt;/em&gt;) and it &lt;strong&gt;renders these in a minimal format&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I started the project about less than 10 days ago, with one goal&lt;/em&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;provide information on the &lt;strong&gt;state of alert about our national lockdown&lt;/strong&gt; for the Christmas holidays;&lt;/li&gt;
&lt;li&gt;provide information on the numbers, &lt;strong&gt;updated daily&lt;/strong&gt;;&lt;/li&gt;
&lt;li&gt;humbly asking &lt;strong&gt;to stay home&lt;/strong&gt;, if not really needed&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;give thanks&lt;/strong&gt; to every doctor, nurse, officer and every single man who have to take care of the other&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://casiimir.github.io/covid-italia/"&gt;WebApp&lt;/a&gt; &lt;br&gt;
 &lt;a href="https://github.com/casiimir/covid-italia"&gt;Repo&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;This is my personal &lt;strong&gt;Christmas Hackathon Project&lt;/strong&gt;.&lt;br&gt;
Maybe it isn't impressive, but &lt;strong&gt;this is my really first project in React that I loved&lt;/strong&gt;. Not for what the code does, but &lt;strong&gt;for what it communicates&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Code needs refactoring, I had to write it quickly, but it works.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I would love to receive your opinion, it's also my first post here!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Wishing you a serene and profitable year, I think we all deserve that.&lt;/p&gt;

&lt;p&gt;(This post was originally posted on my Hashnode &lt;a href="https://casiimir.hashnode.dev/covid19-italy-a-project-for-my-country"&gt;Blog&lt;/a&gt;)&lt;/p&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>frontend</category>
      <category>covid</category>
    </item>
    <item>
      <title>Merry Christmas, by Python</title>
      <dc:creator>casiimir</dc:creator>
      <pubDate>Fri, 25 Dec 2020 16:46:28 +0000</pubDate>
      <link>https://forem.com/casiimir/merry-christmas-by-python-2701</link>
      <guid>https://forem.com/casiimir/merry-christmas-by-python-2701</guid>
      <description>&lt;p&gt;Developers from the four corners of the World, Merry Christmas!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
  &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;' '&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'O'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;' '&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'O'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;-=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
  &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;+=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;' O'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'*'&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'O'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
  &lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;' '&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'#'&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;' '&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Higher Order Function in JS</title>
      <dc:creator>casiimir</dc:creator>
      <pubDate>Thu, 12 Nov 2020 08:58:03 +0000</pubDate>
      <link>https://forem.com/casiimir/higher-order-function-in-js-1hjn</link>
      <guid>https://forem.com/casiimir/higher-order-function-in-js-1hjn</guid>
      <description>&lt;h6&gt;
  
  
  &lt;center&gt;” ‘ THIS, SAID LAYELAH, ‘ IS THE WAY WE HAVE OF ESCAPING. ‘ “&lt;/center&gt;
&lt;/h6&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bQgee9Vk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://howtoreadcode.com/wp-content/uploads/2020/11/higher-order-function-in-javascript.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bQgee9Vk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://howtoreadcode.com/wp-content/uploads/2020/11/higher-order-function-in-javascript.jpg" alt="higher-order-functions"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;powerOf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;exponent&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="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;num&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;num&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="nx"&gt;exponent&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;h1&gt;
  
  
  1. If you can read this, then you’re able to understand the rest
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Higher-order functions&lt;/strong&gt; are functions that operate on other functions, for example, one of these can take functions as arguments or return another function. We can have three different types of these:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Functions inside functions&lt;/li&gt;
&lt;li&gt;Functions that change functions&lt;/li&gt;
&lt;li&gt;Function that manage the control flow&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Lucky for me, we have here an &lt;em&gt;inner&lt;/em&gt; function example inside a mainly function (give a reading to &lt;em&gt;closure&lt;/em&gt;). In this example, &lt;strong&gt;powerOf&lt;/strong&gt; requires an &lt;em&gt;‘exponent‘&lt;/em&gt; parameter and &lt;em&gt;returns an anonymous function&lt;/em&gt;. The latter, accept a ‘num‘ parameter which will be multiplied by itself for &lt;em&gt;‘exponent‘&lt;/em&gt; times (the ** operator was introduced by &lt;em&gt;ECMAScript7&lt;/em&gt;).&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;p&gt;Take a deep breath …&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;powerOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;     &lt;span class="c1"&gt;// powerOf(exponent)(num)&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;64&lt;/span&gt;              &lt;span class="c1"&gt;// 3 times 4 multiplied by itself = 64, wasn't it?&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As a matter of fact, we can try to find a different approach:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;powerOfThree&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;powerOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;powerOfThree&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;64&lt;/span&gt;              &lt;span class="c1"&gt;// Holy abstraction!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hey, check that out! Let’s read it and find out what’s in there. First of all we have assigned the function &lt;em&gt;‘powerOf(3)‘&lt;/em&gt; to &lt;em&gt;‘powerOfThree‘&lt;/em&gt; constant. Makes sense? But beware… &lt;em&gt;powerOfThree&lt;/em&gt; need another argument, namely ‘num‘. So let’s give him num 4 and … ta-dah: it returns 64!&lt;/p&gt;




&lt;h1&gt;
  
  
  2. Becouse when the going gets tough, the tough get going
&lt;/h1&gt;

&lt;p&gt;Higher-order functions are important to understand the three main built-in array methods, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Map&lt;/li&gt;
&lt;li&gt;Filter&lt;/li&gt;
&lt;li&gt;Reduce&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Map&lt;/em&gt; is very simple to understand. It takes a &lt;em&gt;callback&lt;/em&gt;, then, it returns an operation with the same. The operation returns a new array, because map does not mutate the array on which it is called. &lt;strong&gt;How does it works&lt;/strong&gt;?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;array1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;10&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;array2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;array1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;num&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;`Number: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;num&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Well, first of all, &lt;em&gt;the callback is called for every element of the array&lt;/em&gt;, then, each element is added to &lt;em&gt;‘array2‘&lt;/em&gt;. It is very simple to read this code!&lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IB6FHyBA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://howtoreadcode.com/wp-content/uploads/2020/11/map-in-javascript.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IB6FHyBA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://howtoreadcode.com/wp-content/uploads/2020/11/map-in-javascript.jpeg" alt="map-in-javascript"&gt;&lt;/a&gt;&lt;br&gt;
Sometimes we don’t need to use map:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When you don’t use the array that map returns&lt;/li&gt;
&lt;li&gt;When you are not returning any value from the callback&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Well, in these cases, you can use the good ol’ For-of:&lt;/p&gt;



&lt;div class="highlight js-code-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;array1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;10&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;array2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;number&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;array1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;array2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Number: &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="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;








&lt;h1&gt;
  
  
  3. Reinventing the wheel
&lt;/h1&gt;

&lt;p&gt;For a proficient understanding of them &lt;strong&gt;let’s rewrite&lt;/strong&gt;, step-by-step, our personal &lt;em&gt;map&lt;/em&gt; function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;iMap&lt;/span&gt; &lt;span class="o"&gt;=&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;array&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;callback&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;newArray&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;number&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;array&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;newArray&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callback&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="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;newArray&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;Does it make sense? Now try to read it!&lt;br&gt;
(If you feel so lost, don’t worry about that. &lt;em&gt;Logical processes are extremely hard to understand&lt;/em&gt;. So &lt;strong&gt;give yourself time&lt;/strong&gt;!)&lt;br&gt;
&lt;br&gt;&lt;br&gt;&lt;br&gt;
It just so happens that higher-order &lt;strong&gt;functions are related to functional programming paradigm&lt;/strong&gt;. But this is a whole other thing …&lt;/p&gt;






&lt;p&gt;&lt;em&gt;Further reading&lt;/em&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/Callback_(computer_programming)"&gt;Callback - Wiki&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/Higher-order_function"&gt;Higher-order Function- Wiki&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://eloquentjavascript.net/05_higher_order.html"&gt;In Eloquent Javascript&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map"&gt;Map - MDN&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://howtoreadcode.com/higher-order-functions-in-javascript/"&gt;Author post - HowToReadCode&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;






&lt;h6&gt;
  
  
  post scriptum:
&lt;/h6&gt;

&lt;p&gt;&lt;em&gt;I would like it very much any advice about this article, it's my first post on Dev and my first attempt to write few notes in English. Therefore, I thank you for suggestion about that.&lt;/em&gt;&lt;br&gt;
&lt;a href="https://howtoreadcode.com/"&gt;You're Welcome!&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>functional</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Espressioni Regolari in JavaScript</title>
      <dc:creator>casiimir</dc:creator>
      <pubDate>Sat, 26 Sep 2020 12:54:02 +0000</pubDate>
      <link>https://forem.com/casiimir/espressioni-regolari-in-javascript-290</link>
      <guid>https://forem.com/casiimir/espressioni-regolari-in-javascript-290</guid>
      <description>&lt;h2&gt;
  
  
  Una breve introduzione al John Wick delle stringhe
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;L&lt;/strong&gt;e espressioni regolari sono estremamente utilizzate e terribilmente confusionarie. Con l’esperienza, &lt;em&gt;prendendoci la mano&lt;/em&gt;, rimarranno solo terribilmente confusionarie.&lt;/p&gt;

&lt;p&gt;Le &lt;strong&gt;RegExp&lt;/strong&gt; (termine tecnico) sanno essere ragazze veramente difficili da gestire: problema difficile da risolvere, difficoltà maggiori da controllare. Eppure talvolta si rilevano essere l’approccio più veloce, simpatico e soprattutto “pulito”. &lt;strong&gt;Fare la loro conoscenza&lt;/strong&gt; — il che non significa risolvere ogni problemi con esse, anzi — &lt;strong&gt;ci rende dei programmatori più vissuti&lt;/strong&gt;.&lt;br&gt;
Non sono un’esclusiva di &lt;em&gt;Javascript&lt;/em&gt;. Ciò non ci interessa, in questo articolo andremo a vedere proprio come utilizzarle con &lt;em&gt;il linguaggio web più in voga del momento&lt;/em&gt;.&lt;/p&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;“Avete mai sentito l’arcaica espressione trovare un ago nel pagliaio? Sembra essere vecchia di 500 anni. Le espressioni regolari servono proprio a questo: tu indichi il pagliaio, che cosa trovare e loro lo trovano… a dir il vero fanno anche di più: separano l’ago dal pagliaio e, con esso, anche ogni singolo filo di paglia.”&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;



&lt;p&gt;Signori, tra le mani abbiamo forse il tool più potente per processare e ispezionare stringhe di testo, caratteri alfanumerici, numeri, simboli e lettere senza senso. Sono tra i giocattoli dei grandi, e i piccoli sviluppatori — come me — non dovrebbero toccarli. Anche questo non sembra interessarci, andiamo a sporcarci le mani!&lt;/p&gt;

&lt;p&gt;Le espressioni regolari, come quasi ogni cosa in JS, sono di tipo &lt;em&gt;Object&lt;/em&gt; e possono essere richiamate in due modi: usando il costruttore &lt;em&gt;RegExp&lt;/em&gt;; oppure servendoci dei slash di apertura e di chiusura:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let xyz= new RegExp(“xyz”);
let xyz = /xyz/;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;L’uno o l’altro caso significa esclusivamente: &lt;em&gt;questa variabile xyz è un’espressione regolare ‘xyz’&lt;/em&gt;. &lt;strong&gt;Quindi una lettera x seguita da una y a suo volta seguita da una z&lt;/strong&gt;. Niente più, niente meno. Se andassimo ad aprire la console del nostro browser preferito e scrivessimo:&lt;br&gt;
&lt;code&gt;console.log(/xyz/.test(“Che sciocchezza le espressioni regolari”));&lt;/code&gt;&lt;br&gt;
scopriremo che il risultato che ne verrà fuori sarà ineluttabilmente &lt;em&gt;False&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Possiamo “risolvere il problema” studiando un po di più, o cambiando la stringa: &lt;em&gt;le espressioni regolari non sono affatto facili, dice Mr. xyz&lt;/em&gt; — provate su — la nuova stringa passata come parametro della funzione test, prevede la presenza della nostra espressione ricercata, appunto &lt;em&gt;xyz&lt;/em&gt;, sarà costretta a restituire un bel &lt;em&gt;True&lt;/em&gt;.&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;test&lt;/strong&gt; è il metodo più comune: &lt;strong&gt;accetta una frase come parametro e restituisce un tipo Boolean&lt;/strong&gt;. Se la stringa inserita è presente nella nostra frase restituisce un altro bel &lt;em&gt;True&lt;/em&gt;.&lt;/p&gt;



&lt;blockquote&gt;
&lt;p&gt;Per ostacolare ancor più la comprensione, con “stringa” mi riferisco all'espressione regolare e con “frase” alla stringa nella quale andremo a effettuare la ricerca.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/iron/.test(“Guarda c’è ironman!”));
True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Ma metodi per stringhe &lt;em&gt;indexOf&lt;/em&gt; e &lt;em&gt;includes&lt;/em&gt; svolgono praticamente lo stesso compito di questo metodo per le espressioni regolari, &lt;em&gt;test&lt;/em&gt;. Ma fidatevi di Mr. xyz, e portate un po di pazienza: di fatto, per compiti tanto semplici, non si ricorre alle regexp. Le cose cambiano invece quando &lt;strong&gt;dobbiamo cercare&lt;/strong&gt; un insieme di caratteri alfanumerici non ben definiti, seguiti magari da &lt;strong&gt;strani simboli alieni&lt;/strong&gt;… Vediamo qualche esempio.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/\D[0–5][6–9]\D/.test(“Ho appena compiuto 27 anni”);
True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;La seguente espressione si può leggere in questo modo: &lt;strong&gt;dentro la frase “Ho appena compiuto 27 anni” è presente l’espressione \D[0–5][6–9]\D&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;\D sta per “qualsiasi carattere che non sia un numero
[0–4] sta per “qualsiasi numero compreso tra 0 e 4, non ripetuto
[5–9] stessa cosa per sopra ma tra 5 e 9
\D sta nuovamente per “qualsiasi carattere che non sia un numero”
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Analizzando nuovamente con comprendonio la nostra frase vedremo adesso che &lt;strong&gt;ho appena compiuto&lt;/strong&gt; è un insieme di caratteri alfabetici e nessun numero, e che quindi rispetta la definizione \D;&lt;br&gt;
&lt;strong&gt;27&lt;/strong&gt; sono due numeri, precisamente il 2 e il 7, non ripetuti, ove il primo è compreso tra 0–4 e il secondo è compreso tra 5–9;&lt;br&gt;
infine &lt;strong&gt;anni&lt;/strong&gt; sono tutti caratteri alfabetici e nessun numero, rispetta anch'esso \D.&lt;/p&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Da notare come la **built-in-shortcut&lt;/em&gt;* \D accetta più di un carattere o la ripetizione delle stesso o ancora la presenza di uno spazio o di qualsiasi altra cosa che non sia un numero. Mentre la scorciatoia tra parentesi quadre, che abbiamo adottato per la gestione dei numeri interi da 0 a 4, prevede un solo numero, per l’appunto, compreso tra 0 e 4, inclusi.*&lt;/p&gt;
&lt;/blockquote&gt;




&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Lista built-in-shortcut:
\d   Solo numeri
\w   Sia numeri che caratteri alfabetici
\s   Qualsiasi spazio vuoto, tabulazione, linea a capo, et similia
\D   Solo caratteri alfabetici
\W   Solo simboli
\S   Qualsiasi elemento eccezion fatta per gli spazi vuoti, tab, et
     similia
.    Qualsiasi carattere, numero, simbolo e spazio, eccezion fatta
     per il ritorno a capo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Data la tabella sopra, e la breve introduzione all'uso delle parentesi quadre, proviamo ad analizzare un esempio pratico, talvolta anche utile, ma al momento… cosa?!?:&lt;br&gt;
&lt;code&gt;/^[A-Z]{6}\d{2}\D\d{2}\D\d{3}\D$/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;L’espressione soprastante, rullo di tamburi, va a verificare se la frase inserita è un codice fiscale valido. Capisco che ci sono simboli sconosciuti che ancora non sono stati trattati e certamente destano non poche perplessità. Ma &lt;strong&gt;avete scelto voi di imparare a programmare&lt;/strong&gt;, tenetelo a mente; &lt;strong&gt;episodi come questo sono frequenti!&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;^       Identifica l’inizio dell’espressione
[A-Z]   Tutte le parole dalla A alla Z
{6}     Identifica il numero di volte che verrà ripetuto 
        l’elemento precedente (nel caso [A-Z])
\d      Identifica un numero (già visto)
{2}     Nuovamente identifica il numero di volte, in questo caso
        dell’elemento \d
\w      Identifica un carattere
...     e così via, fino a
$       che identifica la fine dell’espressione
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Quindi proviamo a inserire il nostro codice fiscale sulla console e vediamo un po se per il nostro computer siamo tipi &lt;em&gt;True&lt;/em&gt; o &lt;em&gt;False&lt;/em&gt;.&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;test&lt;/strong&gt; non è l’unico metodo a disposizione per la gestione delle espressioni. Diamo una veloce occhiata anche al metodo &lt;strong&gt;replace&lt;/strong&gt;, che sostituisce parti di una stringa, e al metodo &lt;strong&gt;exec&lt;/strong&gt;, che ci restituisce l’indice di riferimento di una porzione di stringa.&lt;/p&gt;


&lt;/blockquote&gt;

&lt;p&gt;Il metodo &lt;strong&gt;replace&lt;/strong&gt;, come suggerisce il nome, &lt;strong&gt;rimpiazza una porzione della nostra frase con un’altra&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;“Ironman”.replace(“man”, “woman”);&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Mentre il metodo &lt;strong&gt;exec restituisce&lt;/strong&gt; un oggetto contenente — tra l’altro — &lt;strong&gt;l’indice di riferimento della porzione di stringa ricercata&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;/\d/.exec(“uno è diverso da 1”);&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Concludiamo in bellezza con un bel sommario semplice e conciso, rubato direttamente da &lt;em&gt;Eloquent Javascript&lt;/em&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/xyz/     La sequenza di caratteri ‘xyz’
/[xyz]/   Almeno uno tra ‘x’ o ‘y’ o ‘z’
/[^xyz]/  Qualunque carattere eccetto la sequenza 
          ‘xyz’
/[0–9]/   Qualunque numero compreso tra 0 e 9
/z+/      Una o più occorrenze del carattere ‘z’
/z*/      Zero o più occorrenze del carattere ‘z’
/z?/      Zero o una occorrenza del carattere ‘z’
/z{2,4}/  Da due a quattro occorrenza del carattere 
          ‘z’
/(xyz)/   Il gruppo della sequenza ‘xyz’
/x|y|z/   Almeno uno tra ‘x’ o ‘y’ o ‘z’
/\d/      Solo numeri
/\w/      Sia numeri che caratteri alfabetici
/\s/      Qualsiasi spazio vuoto, tabulazione, linea a 
          capo, et
          similia
/\D/      Solo caratteri alfabetici
/\W/      Solo simboli
/\S/      Qualsiasi elemento eccezion fatta per gli 
          spazi vuoti, tab, et similia
/./       Qualsiasi carattere, numero, simbolo e 
          spazio, eccezione il ritorno a capo
/^/       Inizio
/$/       Fine
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  &lt;em&gt;A questo punto spero proprio di non aver esagerato, e vi auguro di trovare tutti gli aghi in tutti i vostri pagliai!&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Buona programmazione!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>regex</category>
      <category>beginners</category>
      <category>italian</category>
    </item>
  </channel>
</rss>
