<?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: GiorgiKeburia</title>
    <description>The latest articles on Forem by GiorgiKeburia (@giorgikeburia).</description>
    <link>https://forem.com/giorgikeburia</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%2F691227%2Fc3542010-804a-4f47-bfbe-b022897b354b.jpg</url>
      <title>Forem: GiorgiKeburia</title>
      <link>https://forem.com/giorgikeburia</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/giorgikeburia"/>
    <language>en</language>
    <item>
      <title>Be Carefull With rm!</title>
      <dc:creator>GiorgiKeburia</dc:creator>
      <pubDate>Sun, 10 Oct 2021 23:26:51 +0000</pubDate>
      <link>https://forem.com/giorgikeburia/be-carefull-with-rm-7h9</link>
      <guid>https://forem.com/giorgikeburia/be-carefull-with-rm-7h9</guid>
      <description>&lt;p&gt;📣 The world is amazing ,but Not so ideal as we think!🤔&lt;/p&gt;

&lt;p&gt;💡 Unix-like operating systems such as Linux do not have an &lt;strong&gt;undelete&lt;/strong&gt; command.&lt;/p&gt;

&lt;p&gt;When we delete something with rm , it's gone.Linux assumes we're smart and we know what we're doing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/de5bARu0SsXiU/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/de5bARu0SsXiU/giphy.gif" alt="Giff"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One of the big problem can cause wildcards. so be particularly with them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For Example&lt;/strong&gt; : if we want to delete just the JS files in directory we type:&lt;br&gt;
&lt;code&gt;rm *.js&lt;/code&gt;&lt;br&gt;
Of course this is correct , but if we accidentally place a space between the &lt;strong&gt;*&lt;/strong&gt; and the &lt;strong&gt;.js&lt;/strong&gt; like so:&lt;br&gt;
&lt;code&gt;rm * .js&lt;/code&gt;&lt;br&gt;
what happens? 🤔🧐&lt;br&gt;
the rm command will delete al the files in the directory and only then complain that there is no file called &lt;strong&gt;.js&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There is many ways to avoid this problem, here is 2 useful tip: &lt;br&gt;
1 - use &lt;strong&gt;-i&lt;/strong&gt; (interactive) option, which prompt the user for confirmation  ,before deleting an existing file.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;rm i *.js&lt;/code&gt;&lt;br&gt;
  asks -&amp;gt; &lt;code&gt;rm: remove regular empty file 'mk.js'?&lt;/code&gt;&lt;br&gt;
2 - whenever we use wildcards with rm, test the wildcard first with ls. This will let we see the files that will be deleted. Then we can press the up arrow ☝️ to recall the command and replace ls with rm.&lt;/p&gt;

</description>
      <category>linux</category>
    </item>
    <item>
      <title>Important Array Functions In JS </title>
      <dc:creator>GiorgiKeburia</dc:creator>
      <pubDate>Thu, 30 Sep 2021 10:20:29 +0000</pubDate>
      <link>https://forem.com/giorgikeburia/important-array-functions-in-js-30a4</link>
      <guid>https://forem.com/giorgikeburia/important-array-functions-in-js-30a4</guid>
      <description>&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%2F4ehyf8q97hozlo8gyrwa.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%2F4ehyf8q97hozlo8gyrwa.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
In programming, an array is a collection of elements or items. The array data structure is widely used in all programming languages that support it.&lt;/p&gt;

&lt;p&gt;In this Article, I'll show you a short Overview of the most important array methods in JavaScript:&lt;/p&gt;

&lt;h2&gt;
  
  
  Array.map()
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;map()&lt;/strong&gt; method creates a new array populated with the results of calling a provided function on every element in the calling array.&lt;br&gt;
A new array with each element being the result of the callback function.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    const array1 = [1, 4, 9, 16];

   // pass a function to map
   const map1 = array1.map(x =&amp;gt; x * 2);

   console.log(map1);
   // expected output: Array [2, 8, 18, 32]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map" rel="noopener noreferrer"&gt;for more information&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Array.find()
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;find()&lt;/strong&gt; method returns the value of the first element in the provided array that satisfies the provided testing function. If no values satisfy the testing function, undefined is returned.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    const array1 = [5, 12, 8, 130, 44];

    const found = array1.find(element =&amp;gt; element &amp;gt; 10);

    console.log(found);
    // expected output: 12
    console.log(map1);
    // expected output: Array [2, 8, 18, 32]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find" rel="noopener noreferrer"&gt;for more information&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Array.findIndex()
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;findIndex()&lt;/strong&gt; method returns the index of the first element in the array that satisfies the provided testing function. Otherwise, it returns -1, indicating that no element passed the test.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    const array1 = [5, 12, 8, 130, 44];

    const isLargeNumber = (element) =&amp;gt; element &amp;gt; 13;

    console.log(array1.findIndex(isLargeNumber));
    // expected output: 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex" rel="noopener noreferrer"&gt;for more information&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Array.splice()
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;splice()&lt;/strong&gt; method changes the contents of an array by removing or replacing existing elements and/or adding new elements in place. To access part of an array without modifying it, see slice().&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    const months = ['Jan', 'March', 'April', 'June'];
    months.splice(1, 0, 'Feb');
    // inserts at index 1
    console.log(months);
    // expected output: Array ["Jan", "Feb", "March", "April", "June"]

    months.splice(4, 1, 'May');
    // replaces 1 element at index 4
    console.log(months);
    // expected output: Array ["Jan", "Feb", "March", "April", "May"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice" rel="noopener noreferrer"&gt;for more information&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Array.slice()
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;slice()&lt;/strong&gt; method returns a shallow copy of a portion of an array into a new array object selected from start to end (end not included) where start and end represent the index of items in that array. The original array will not be modified.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    const animals = ['ant', 'bison', 'camel', 'duck', 'elephant'];

    console.log(animals.slice(2));
    // expected output: Array ["camel", "duck", "elephant"]

    console.log(animals.slice(2, 4));
    // expected output: Array ["camel", "duck"]

    console.log(animals.slice(1, 5));
    // expected output: Array ["bison", "camel", "duck", "elephant"]

    console.log(animals.slice(-2));
    // expected output: Array ["duck", "elephant"]

    console.log(animals.slice(2, -1));
    // expected output: Array ["camel", "duck"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice" rel="noopener noreferrer"&gt;for more information&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Array.concat()
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;concat()&lt;/strong&gt; method is used to merge two or more arrays. This method does not change the existing arrays, but instead returns a new array.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    const array1 = ['a', 'b', 'c'];
    const array2 = ['d', 'e', 'f'];
    const array3 = array1.concat(array2);

    console.log(array3);
    // expected output: Array ["a", "b", "c", "d", "e", "f"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat?v=b" rel="noopener noreferrer"&gt;for more information&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Array.reduce()
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;reduce()&lt;/strong&gt; method executes a user-supplied “reducer” callback function on each element of the array, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the array is a single value.&lt;/p&gt;

&lt;p&gt;Perhaps the easiest-to-understand case for reduce() is to return the sum of all the elements in an array.&lt;/p&gt;

&lt;p&gt;The reducer walks through the array element-by-element, at each step adding the current array value to the result from the previous step (this result is the running sum of all the previous steps) — until there are no more elements to add.&lt;/p&gt;

&lt;p&gt;This is shown in the following interactive example:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   const array1 = [1, 2, 3, 4];
   const reducer = (previousValue, currentValue) =&amp;gt; previousValue + currentValue;

   // 1 + 2 + 3 + 4
   console.log(array1.reduce(reducer));
   // expected output: 10

   // 5 + 1 + 2 + 3 + 4
   console.log(array1.reduce(reducer, 5));
   // expected output: 15
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce?v=b" rel="noopener noreferrer"&gt;for more information&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Array.filter()
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;filter()&lt;/strong&gt; method creates a new array with all elements that pass the test implemented by the provided function.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];

   const result = words.filter(word =&amp;gt; word.length &amp;gt; 6);

   console.log(result);
   // expected output: Array ["exuberant", "destruction", "present"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter" rel="noopener noreferrer"&gt;for more information&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>functional</category>
    </item>
  </channel>
</rss>
