<?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: aidoskashenov</title>
    <description>The latest articles on DEV Community by aidoskashenov (@aidoskashenov).</description>
    <link>https://dev.to/aidoskashenov</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%2F422466%2F17f39ed2-53e6-43a2-96cf-ed3bd25da00d.png</url>
      <title>DEV Community: aidoskashenov</title>
      <link>https://dev.to/aidoskashenov</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aidoskashenov"/>
    <language>en</language>
    <item>
      <title>Syntax Podcast: JSON, JSNONP and CORS</title>
      <dc:creator>aidoskashenov</dc:creator>
      <pubDate>Sun, 23 Aug 2020 14:11:09 +0000</pubDate>
      <link>https://dev.to/aidoskashenov/syntax-podcast-json-jsnonp-and-cors-bgn</link>
      <guid>https://dev.to/aidoskashenov/syntax-podcast-json-jsnonp-and-cors-bgn</guid>
      <description>&lt;p&gt;When you try to fetch data from another source, you have to use JSON(Javascript Object Notation). JSON allows the API to be turned into &lt;code&gt;string&lt;/code&gt;, that is very easy to move, and then after the &lt;code&gt;fetch&lt;/code&gt;, &lt;code&gt;parse&lt;/code&gt; it back to an object. By default two separate browser entities cannot access to one another's data, because otherwise they could make changes and pull out sensitive information. However, there are ways to share data across websites. &lt;/p&gt;

&lt;p&gt;JSONP - is JSON with padding is an addition to a JSON format and it allows to request the API from another domain. You can only do that if the providing website gives the permission. The way it works, is that you cannot load data cross origin, but you can load Javascript cross origin, so the work around is that you have to wrap the data into a Javascript callback function and pass it that way.&lt;/p&gt;

&lt;p&gt;CORS - stands for cross-origin resource sharing, and is a mechanism that allows restricted resources on a web page to be requested from another domain outside the domain from which the first resource was served. A web page may freely embed cross-origin images, stylesheets, scripts, iframes, and videos. &lt;br&gt;
With CORS you can designate the number of URLs that can take data from your website. You can use &lt;code&gt;Access-Control-Allow-Origin: *&lt;/code&gt; allow access to any website, however it can be very risky for your application. CORS are very important to be aware of, because one way or another, dealing with data you run into it, and you have to know how to properly deal with it.  &lt;/p&gt;

</description>
    </item>
    <item>
      <title>React Hooks</title>
      <dc:creator>aidoskashenov</dc:creator>
      <pubDate>Wed, 05 Aug 2020 02:21:53 +0000</pubDate>
      <link>https://dev.to/aidoskashenov/react-hooks-4kfb</link>
      <guid>https://dev.to/aidoskashenov/react-hooks-4kfb</guid>
      <description>&lt;h1&gt;
  
  
  React Hooks
&lt;/h1&gt;

&lt;p&gt;React was created by Jordan Walke, a software engineer at Facebook, who released an early prototype of React called "FaxJS". He was influenced by XHP, an HTML component library for PHP. It was first deployed on Facebook's News Feed in 2011 and later on Instagram in 2012.It was open-sourced at JSConf US in May 2013.&lt;br&gt;
However, only after 8 years, On February 16, 2019, React 16.8 was released to the public,the release introduced React Hooks.&lt;/p&gt;

&lt;p&gt;Hooks are functions that let developers "hook into" React state and lifecycle features from function components. They make codes readable and easily understandable. Average developer spend one tenth of time writing code and the rest  reading and digging through his or someone else's composure. React hooks make this process way easier, hooks don’t work inside classes ,instead they let you use React without classes.&lt;/p&gt;

&lt;p&gt;React provides a few built-in Hooks like &lt;code&gt;useState&lt;/code&gt;, &lt;code&gt;useContext&lt;/code&gt;, &lt;code&gt;useReducer&lt;/code&gt; and &lt;code&gt;useEffect&lt;/code&gt; to name a few. They are all stated in the Hooks API Reference, &lt;code&gt;useState&lt;/code&gt; and &lt;code&gt;useEffect&lt;/code&gt;, which are the most used, are for controlling states and side effects respectively in React Components and &lt;code&gt;useEffect&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;There are rules of hooks which must be followed before they can be used. Hooks should only be called at the top level (not inside loops or if statements)and they should only be called from React function components, not normal functions or class components&lt;/p&gt;

&lt;p&gt;Essentially the biggest benefit of the React hooks is that when you use classes you end up with complex components with stateful logic. It is hard to deal with those components because they relies on the React Lifecycle methods. Instead hooks allow you  to break those components into smaller functions and incapsulate them into smaller units, which you can use depending on the functionality.&lt;/p&gt;

&lt;p&gt;The two most used React Hooks are &lt;code&gt;useState&lt;/code&gt; and &lt;code&gt;useEffect&lt;/code&gt;, the first basically is a substitute to &lt;code&gt;class component&lt;/code&gt; and the second is a substitute for &lt;code&gt;componentDidMount()&lt;/code&gt; and &lt;code&gt;componentDidUpdate&lt;/code&gt;, however there a bunch of other useful React Hooks and ,what's even more fascinating, you can write and invent your own hooks which you can store and use in accordance to your functionality.&lt;/p&gt;

&lt;p&gt;In conclusion we can definitely say that React Hooks is a relatively new feature, however very powerful and with a immense potential that is still growing and expanding. &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>hooks</category>
    </item>
    <item>
      <title>Syntax Takeaways</title>
      <dc:creator>aidoskashenov</dc:creator>
      <pubDate>Thu, 30 Jul 2020 23:26:04 +0000</pubDate>
      <link>https://dev.to/aidoskashenov/syntax-takeaways-3m91</link>
      <guid>https://dev.to/aidoskashenov/syntax-takeaways-3m91</guid>
      <description>&lt;p&gt;&lt;code&gt;React&lt;/code&gt; is a very dynamic environment, it is changing, updating and developing quite rapidly and hooks are the latest and a very significant implementation into React logic. You cannot say that hooks made classes, render props, aka previous way of doing things, obsolete, however hooks makes using React way simpler and more intuitive.The developers made possible for hooks to be opted-in so you don't have to rewrite your code completely. Before, render props there were mix-ins and they were removed.&lt;br&gt;
Hooks are solving the problem of adding state to the stateless functional component. If you created a stateless functional component but then at some point you would have to add state to that component you would  have to turn it into class component and it can be very difficult. &lt;br&gt;
Hooks are made to inject functionality into "dumb" components. Hooks can be created by developers and implemented for specific problems along the way,there are some very popular like: &lt;code&gt;Context hooks&lt;/code&gt;, &lt;code&gt;Effect hooks&lt;/code&gt;, &lt;code&gt;Reducer hooks&lt;/code&gt; and &lt;code&gt;Ref hooks&lt;/code&gt;  however, the most usable hook right now is &lt;code&gt;State hooks&lt;/code&gt; - &lt;code&gt;useState&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;State Hooks&lt;/em&gt;&lt;br&gt;
&lt;code&gt;useState&lt;/code&gt; is a replacement of a &lt;code&gt;SetState&lt;/code&gt; component in a class syntax. Before executing a &lt;code&gt;return&lt;/code&gt;, &lt;code&gt;useState&lt;/code&gt; declares a 'state' variable, that way we can 'save' some values, between invocations. It is a way substitute &lt;code&gt;this.state&lt;/code&gt; functions. &lt;code&gt;useState&lt;/code&gt; returns a couple of values: present state and a function that refreshing the state.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Effect Hooks&lt;/em&gt;&lt;br&gt;
&lt;code&gt;useEffect&lt;/code&gt; hook allows you to access the data inside the component. Effect hooks can be used as a substitute to the lifecycle methods like: "Component Did Mount", "Component did Update" and "Component will Unmount".  What it does is, when you have an "unpure" function and you don't have a React component, &lt;br&gt;
you do have to write code for those components. Effect hook solves this problem. Also, previously you had to pass logic into each component and it could lead to potential difficulties, however now, you can build a special hook to store that logic.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Reducer Hooks&lt;/em&gt;&lt;br&gt;
&lt;code&gt;useReducer&lt;/code&gt; hook is a less used, however it allows functional components in React access to reducer functions from your state management. Reducer is a function that takes in the current state,as well as a specified action. Inside of your reducer function you can store multiple use cases. According to the use case you can access specific data return an updated state. &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>hooks</category>
    </item>
    <item>
      <title>A reintroduction to Javascript</title>
      <dc:creator>aidoskashenov</dc:creator>
      <pubDate>Sun, 26 Jul 2020 16:39:45 +0000</pubDate>
      <link>https://dev.to/aidoskashenov/a-reintroduction-to-javascript-38pp</link>
      <guid>https://dev.to/aidoskashenov/a-reintroduction-to-javascript-38pp</guid>
      <description>&lt;p&gt;Reading most of the reintroduction I didn't found anything new up until, control structures, most of the things there: &lt;code&gt;Numbers,&lt;/code&gt;Strings&lt;code&gt;,&lt;/code&gt;Booleans&lt;code&gt;and&lt;/code&gt;Symbols`. However I found something very interesting and for me in the introduction section, about how JS is a misunderstood language. &lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;Unlike&lt;/span&gt; &lt;span class="nx"&gt;most&lt;/span&gt; &lt;span class="nx"&gt;programming&lt;/span&gt; &lt;span class="nx"&gt;languages&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;the&lt;/span&gt; &lt;span class="nx"&gt;JavaScript&lt;/span&gt; &lt;span class="nx"&gt;language&lt;/span&gt; &lt;span class="nx"&gt;has&lt;/span&gt; &lt;span class="nx"&gt;no&lt;/span&gt; &lt;span class="nx"&gt;concept&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;or&lt;/span&gt; &lt;span class="nx"&gt;output&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="nx"&gt;It&lt;/span&gt; &lt;span class="nx"&gt;is&lt;/span&gt; &lt;span class="nx"&gt;designed&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="nx"&gt;run&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;scripting&lt;/span&gt; &lt;span class="nx"&gt;language&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;host&lt;/span&gt; &lt;span class="nx"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;and&lt;/span&gt; &lt;span class="nx"&gt;it&lt;/span&gt; &lt;span class="nx"&gt;is&lt;/span&gt; &lt;span class="nx"&gt;up&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="nx"&gt;the&lt;/span&gt; &lt;span class="nx"&gt;host&lt;/span&gt; &lt;span class="nx"&gt;environment&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="nx"&gt;provide&lt;/span&gt; &lt;span class="nx"&gt;mechanisms&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nx"&gt;communicating&lt;/span&gt; &lt;span class="kd"&gt;with&lt;/span&gt; &lt;span class="nx"&gt;the&lt;/span&gt; &lt;span class="nx"&gt;outside&lt;/span&gt; &lt;span class="nx"&gt;world&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="nx"&gt;The&lt;/span&gt; &lt;span class="nx"&gt;most&lt;/span&gt; &lt;span class="nx"&gt;common&lt;/span&gt; &lt;span class="nx"&gt;host&lt;/span&gt; &lt;span class="nx"&gt;environment&lt;/span&gt; &lt;span class="nx"&gt;is&lt;/span&gt; &lt;span class="nx"&gt;the&lt;/span&gt; &lt;span class="nx"&gt;browser&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;but&lt;/span&gt; &lt;span class="nx"&gt;JavaScript&lt;/span&gt; &lt;span class="nx"&gt;interpreters&lt;/span&gt; &lt;span class="nx"&gt;can&lt;/span&gt; &lt;span class="nx"&gt;also&lt;/span&gt; &lt;span class="nx"&gt;be&lt;/span&gt; &lt;span class="nx"&gt;found&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;huge&lt;/span&gt; &lt;span class="nx"&gt;list&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;other&lt;/span&gt; &lt;span class="nx"&gt;places&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This particular piece, made me understand why Javascript is such a popular programming language and is a powerful tool for programming in general.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Control Structures&lt;/strong&gt;&lt;br&gt;
The switch statement can be used for multiple branches based on a number or string:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;switch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;draw&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nx"&gt;drawIt&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;eat&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nx"&gt;eatIt&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;default&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nx"&gt;doNothing&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;&lt;code&gt;Switch&lt;/code&gt; is essentially like &lt;code&gt;if&lt;/code&gt; , &lt;code&gt;else&lt;/code&gt; however it has a &lt;code&gt;break&lt;/code&gt; keyword, a statement to 'break out' of the switch statement and continue to the next block of code. Without the break statement additional blocks may be executed if the evaluation matches the case value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Objects&lt;/strong&gt;&lt;br&gt;
Starting in ECMAScript 2015, object keys can be defined by the variable using bracket notation upon being created.&lt;br&gt;
~~~js {[phoneType]: 12345} is possible instead of just var userPhone = {}; userPhone[phoneType] = 12345.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
**Arrays**
Sometimes `array.length` would not equate to the number of elements inside the `array`
~~~js
var a = ['dog', 'cat', 'hen'];
a[100] = 'fox';
a.length; // 101
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;If you do something like that, you will have 4 elements in the array, however the &lt;code&gt;array.length&lt;/code&gt; will be 101&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Functions&lt;/strong&gt;&lt;br&gt;
Javascript is very liberal with the use and declaration of the function overall. You don't have to pass parameters to the function upon declaration, you can pass several parameters and then pass a different number of arguments, upon invoking, and still JS will let you compile the code. So far as I know it is strictly prohibited in most of the languages.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Object.prototype&lt;/code&gt; is a little bit hard to wrap your head around this concept, however, as far as I understand a prototype is an instance of the parental method and whenever you are accessing the attributes of the prototype, the prototype is having most of the features and methods that we want the child to inherit.&lt;/p&gt;

&lt;p&gt;You can use nested function to make your code cleaner to avoid congestion. You can also store your variables for the nested function inside the parental function, right above, that will make sure that you are not making excessive global functions.&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>.sort and  .pop</title>
      <dc:creator>aidoskashenov</dc:creator>
      <pubDate>Mon, 20 Jul 2020 16:32:19 +0000</pubDate>
      <link>https://dev.to/aidoskashenov/sort-and-pop-2i8g</link>
      <guid>https://dev.to/aidoskashenov/sort-and-pop-2i8g</guid>
      <description>&lt;p&gt;&lt;code&gt;Javascript&lt;/code&gt; has a variety of built-in Array methods that empower the developer to bend and shape huge amount of data at his will. From very simple like &lt;code&gt;.length&lt;/code&gt; or &lt;code&gt;.push&lt;/code&gt; to more complex, like &lt;code&gt;.reduce&lt;/code&gt; or &lt;code&gt;.every&lt;/code&gt;. We will take a look at a look at &lt;code&gt;.pop&lt;/code&gt; and &lt;code&gt;.sort&lt;/code&gt; methods.&lt;/p&gt;

&lt;h1&gt;
  
  
  Array.prototype.pop()
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;Array.prototype.pop()&lt;/code&gt; cuts the last element of the &lt;code&gt;array&lt;/code&gt; and brings it back to you&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;fruits&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Banana&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Orange&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Apple&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Mango&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="nx"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fruits&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// ["Banana", "Orange", "Apple", "Mango"]&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;popped&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;fruits&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;();&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;fruits&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// ["Banana", "Orange", "Apple"]&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;popped&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// "Mango"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;It is a very simple and straightforward method, however you always have to keep in mind that &lt;code&gt;.pop&lt;/code&gt; method mutates the initial &lt;code&gt;array&lt;/code&gt; and it can lead to a potential bug in the future, if you are using this method without awarness.&lt;/p&gt;

&lt;h1&gt;
  
  
  Array.prototype.sort()
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;Array.prototype.sort()&lt;/code&gt; ,whenever invoked, sorts the &lt;code&gt;array&lt;/code&gt; in the alphabetical order, according to UTF-16 standard:&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;myArray&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Bob&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Bully&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Amy&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="nx"&gt;myArray&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;// myArray becomes ["Amy", "Bob", "Bully"]&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;myArray&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Given the &lt;code&gt;number&lt;/code&gt; the sort method will treat them as a string and will still sort them in "alphabetical" order and not by the value of the number: &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;myArray&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;40&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;span class="nx"&gt;myArray&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;()&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;myArray&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;//  myArray becomes [300,40,7]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This happens because Javascript sorts the array in the lexicographical order and it deems that &lt;code&gt;300&lt;/code&gt; as a string comes before '40' and '7' because in lexicographical order '3' comes before '4' and '0' is just an extension. &lt;/p&gt;

&lt;p&gt;To get the results that we need with numbers we have to pass in a sorting function as an argument to &lt;code&gt;.sort&lt;/code&gt; method: &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;sortfunction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="err"&gt;—&lt;/span&gt; &lt;span class="nx"&gt;b&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;This function compares two adjacent elements by subtracting the second from the first. There are three possible outcomes: '0', '&amp;lt;0' and '&amp;gt;0'. If the outcomes equals to zero it means that the elements are equal and no swapping required. If the outcome is greater than zero than swapping is required because element &lt;code&gt;a&lt;/code&gt; is greater than element &lt;code&gt;b&lt;/code&gt;. If the outcome is negative that means that the elements are already in order and the swapping is not required:&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;myArray&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;25&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;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;41&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="nx"&gt;myArray&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sort&lt;/span&gt;&lt;span class="p"&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;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;b&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;a&lt;/span&gt; &lt;span class="err"&gt;—&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;
&lt;span class="p"&gt;})&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;myArray&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;//  myArray will be[7, 8, 25, 41]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;However, the sort method would not have much of a use if we could sort only simple arrays consisting of &lt;code&gt;Strings&lt;/code&gt; and &lt;code&gt;Numbers&lt;/code&gt;. Luckily, we can use &lt;code&gt;.sort&lt;/code&gt; method to sort complex data, like an &lt;code&gt;array&lt;/code&gt; of &lt;code&gt;objects&lt;/code&gt;. Say we have an &lt;code&gt;array&lt;/code&gt; of employees with their names and retired data:&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;employees&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="nx"&gt;employees&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;George&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;retiredate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;March 12, 2014&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;employees&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Edward&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;17&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;retiredate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;June 2, 2023&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;employees&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="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Christine&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;58&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;retiredate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;December 20, 2036&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;employees&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="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Sarah&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;62&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;retiredate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;April 30, 2020&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;We can sort our employees by any property, all we have to do is pass the property as an element in our comparing function. Lets sort them by their age (which is a little bit questionable form the "political correctness" point):&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;employees&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sort&lt;/span&gt;&lt;span class="p"&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;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&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;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;
&lt;span class="p"&gt;})&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;employees&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="cm"&gt;/**[
  { name: 'Edward', age: 17, retiredate: 'June 2, 2023' },
  { name: 'George', age: 32, retiredate: 'March 12, 2014' },
  { name: 'Christine', age: 58, retiredate: 'December 20, 2036' },
  { name: 'Sarah', age: 62, retiredate: 'April 30, 2020' }
]*/&lt;/span&gt;

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

&lt;p&gt;We can see that "Edward" and "George" changed their places in the array according to their age. Should you ever want to sort the array in the opposite order, all you have to do is apply &lt;code&gt;.reverse&lt;/code&gt; method on the sorted array.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;.sort&lt;/code&gt; method is a powerful tool when dealing with the data, however you should keep in mind that it is a mutating method and will change the initial array.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Javascript vs Ruby</title>
      <dc:creator>aidoskashenov</dc:creator>
      <pubDate>Mon, 13 Jul 2020 16:33:37 +0000</pubDate>
      <link>https://dev.to/aidoskashenov/javascript-vs-ruby-4k9k</link>
      <guid>https://dev.to/aidoskashenov/javascript-vs-ruby-4k9k</guid>
      <description>&lt;p&gt;Being a complete novice in `Javascript` and having some very limited exposure to `Ruby` I can already point out some distinctions and similarities of syntax and overall logic in two languages. &lt;/p&gt;

&lt;p&gt;I'm guessing that my list will cover only 5% of overall differences and similarities between the two, however this is strictly a description of my personal experience and attitude overall.&lt;br&gt;
As in &lt;code&gt;JS&lt;/code&gt; in &lt;code&gt;Ruby&lt;/code&gt; the &lt;code&gt;Strings&lt;/code&gt;, &lt;code&gt;Numbers&lt;/code&gt;, &lt;code&gt;Booleans&lt;/code&gt;, &lt;code&gt;Arrays&lt;/code&gt; and Objects are the same. However Objects are called Hashes in Ruby and are dealt with slightly different. Another, pleasant surprise for me was that a lot of  built-in methods are the same and have  same, or almost same name. For Example: &lt;code&gt;.length&lt;/code&gt; &lt;code&gt;.forEach&lt;/code&gt; &lt;code&gt;.push&lt;/code&gt; &lt;code&gt;.pop&lt;/code&gt; &lt;code&gt;.unshift&lt;/code&gt; etc.&lt;br&gt;
However, right now, on my second week of learning &lt;code&gt;Javascript&lt;/code&gt; my biggest challenge is dealing with the syntax and overall layout of the code, mostly this - &lt;code&gt;"{"&lt;/code&gt; thing. What in Ruby dealt with "end" statement, &lt;code&gt;JS&lt;/code&gt; puts in &lt;code&gt;"{"&lt;/code&gt; that, for me personally, makes it harder to trace one piece of logic, it's starting and ending point.&lt;br&gt;
Another very interesting thing for me, was that you can add a &lt;code&gt;"String"&lt;/code&gt; to a &lt;code&gt;"Number"&lt;/code&gt; or a &lt;code&gt;"null"&lt;/code&gt; to basically anything. Ruby will immediately protest such a behavior giving out:"TypeError: no implicit conversion from &lt;code&gt;nil&lt;/code&gt; to &lt;code&gt;integer&lt;/code&gt;". In Ruby you cannot concat any type of data to another type without convert it to the same. &lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="mi"&gt;21&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;21&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;2121&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="c1"&gt;// in Ruby will look like this&lt;/span&gt;
&lt;span class="mi"&gt;21&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;to_s&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;21&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;2121&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;There are many more differences between two languages that I am very anticipated to explore&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>ruby</category>
    </item>
    <item>
      <title>Data Types in Javascript</title>
      <dc:creator>aidoskashenov</dc:creator>
      <pubDate>Mon, 13 Jul 2020 16:00:19 +0000</pubDate>
      <link>https://dev.to/aidoskashenov/data-types-in-javascript-3fag</link>
      <guid>https://dev.to/aidoskashenov/data-types-in-javascript-3fag</guid>
      <description>&lt;h1&gt;
  
  
  Data Types In Javascript
&lt;/h1&gt;

&lt;p&gt;There are 3 types of data types in Javascript: primitive and composite and data types. &lt;br&gt;
Primitive data types are simple types like "Strings", Number, Boolean, &lt;em&gt;undefined&lt;/em&gt; and &lt;em&gt;null&lt;/em&gt;. Composite data are Arrays, Objects and Functions. &lt;br&gt;
Primitive data types are those that can hold only one type of value and cannot be subject to use of a methods, whereas objects and arrays can hold multiple data units and all the methods and functions are using objects as their arguments. Everything is an Object in Javascript and that's why Javascript is called an &lt;em&gt;Object Oriented Language&lt;/em&gt;&lt;br&gt;
However, some of the sources distinguish 3 types of data separating &lt;em&gt;undefined&lt;/em&gt; and &lt;em&gt;null&lt;/em&gt; as a "special" data type. These two types can be confusing, but to put it simply, &lt;em&gt;undefined&lt;/em&gt; means that a variable was never defined in the code, and null means that there is no value.&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>Data Types In Javascript</title>
      <dc:creator>aidoskashenov</dc:creator>
      <pubDate>Mon, 06 Jul 2020 02:23:11 +0000</pubDate>
      <link>https://dev.to/aidoskashenov/data-types-in-javascript-4ob9</link>
      <guid>https://dev.to/aidoskashenov/data-types-in-javascript-4ob9</guid>
      <description>&lt;p&gt;There are 3 types of data types in Javascript: primitive and composite and data types. &lt;br&gt;
Primitive data types are simple types like "Strings", Number, Boolean, &lt;em&gt;undefined&lt;/em&gt; and &lt;em&gt;null&lt;/em&gt;. Composite data are Arrays, Objects and Functions. &lt;br&gt;
Primitive data types are those that can hold only one type of value and cannot be subject to use of a methods, whereas objects and arrays can hold multiple data units and all the methods and functions are using objects as their arguments. Everything is an Object in Javascript and that's why Javascript is called an &lt;em&gt;Object Oriented Language&lt;/em&gt;&lt;br&gt;
However, some of the sources distinguish 3 types of data separating &lt;em&gt;undefined&lt;/em&gt; and &lt;em&gt;null&lt;/em&gt; as a "special" data type. These two types can be confusing, but to put it simply, &lt;em&gt;undefined&lt;/em&gt; means that a variable was never defined in the code, and null means that there is no value.&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>Post #1</title>
      <dc:creator>aidoskashenov</dc:creator>
      <pubDate>Thu, 02 Jul 2020 17:10:10 +0000</pubDate>
      <link>https://dev.to/aidoskashenov/post-1-h2c</link>
      <guid>https://dev.to/aidoskashenov/post-1-h2c</guid>
      <description>&lt;p&gt;Hi, Everyone, this is my first week at ClaimAcademy bootcamp. I was working as a cable technician at Spectrum before and tried some coding on my own. After several month I decided to join ClaimAcademy and I am very happy that I did&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
