<?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: Taguhi Manukyan</title>
    <description>The latest articles on DEV Community by Taguhi Manukyan (@taguhi_manukyan_73ffa9e44).</description>
    <link>https://dev.to/taguhi_manukyan_73ffa9e44</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%2F926373%2Fbd52a438-74ae-4c99-a61a-65393bdb2587.png</url>
      <title>DEV Community: Taguhi Manukyan</title>
      <link>https://dev.to/taguhi_manukyan_73ffa9e44</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/taguhi_manukyan_73ffa9e44"/>
    <language>en</language>
    <item>
      <title>Functions in Java Script</title>
      <dc:creator>Taguhi Manukyan</dc:creator>
      <pubDate>Wed, 09 Nov 2022 20:49:04 +0000</pubDate>
      <link>https://dev.to/taguhi_manukyan_73ffa9e44/functions-in-java-script-2ibi</link>
      <guid>https://dev.to/taguhi_manukyan_73ffa9e44/functions-in-java-script-2ibi</guid>
      <description>&lt;p&gt;Let's start with the general understanding.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a function in general?&lt;/strong&gt;&lt;br&gt;
A function is a group of code that performs a specific task. When you define a function, you can call it everywhere and do a particular action.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why do people create functions?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;1) Functions Encapsulate Tasks - often functions named "black boxes" because when we call them, we do not care what the inner code of it is. We need just its result.&lt;/p&gt;

&lt;p&gt;2)Functions Separate Tasks - programmers can cleanly divide their code into segments to work with it efficiently.&lt;/p&gt;

&lt;p&gt;3)Functions Let You Reuse Code - often, we reuse the same code multiple times, and not to repeat ourselves, we can write functions once and call them when needed.  &lt;/p&gt;

&lt;p&gt;4)Functions Make Testing and Debugging Easier - often, we make mistakes in our code, and it is easier to correct errors in one place and make sure it works appropriately and then call when needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Java Script functions
&lt;/h2&gt;

&lt;p&gt;In JavaScript function is a block of code to perform a task, and we can use it when we call it and input arguments if needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Function Declaration
&lt;/h2&gt;

&lt;p&gt;To create a function, we have to.&lt;/p&gt;

&lt;p&gt;1) &lt;strong&gt;write "function" keyword&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;2) &lt;strong&gt;give a name to our function&lt;/strong&gt;&lt;br&gt;
     naming a function has the same rules as naming variables.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; a)Names can contain letters, digits, underscores, and 
 dollar signs.

 b)Names must begin with a letter.

 c)Names can also begin with '$' and '_.'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;3) &lt;strong&gt;write parenthesis "()"&lt;/strong&gt;&lt;br&gt;
4) &lt;strong&gt;open curly brackets "{}"&lt;/strong&gt;&lt;br&gt;
5) &lt;strong&gt;write the logic of a code&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZO_cECRM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/we52mzaxqbxzfeqt8tot.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZO_cECRM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/we52mzaxqbxzfeqt8tot.jpeg" alt="Image description" width="880" height="158"&gt;&lt;/a&gt;&lt;br&gt;
6)&lt;strong&gt;return object which we want to get as output from the function&lt;/strong&gt;&lt;br&gt;
When the code reaches the command 'return,' it automatically stops execution and returns the variable's value.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0qLfViet--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nf5fzwe4udadg8y0h9bu.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0qLfViet--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nf5fzwe4udadg8y0h9bu.jpeg" alt="Image description" width="880" height="160"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Functions can also be defined as regular variables &lt;br&gt;
1) keyword 'let,' 'var,' or 'const.'&lt;br&gt;
2) function's name&lt;br&gt;
3) equal sign '='&lt;br&gt;
4) function()&lt;br&gt;
5) curly brackets '{}.'&lt;br&gt;
6) logic of the function&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GsthZo71--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s67uxfp7mhmkhnd4k3b8.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GsthZo71--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s67uxfp7mhmkhnd4k3b8.jpeg" alt="Image description" width="880" height="248"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Function Invocation
&lt;/h2&gt;

&lt;p&gt;We write functions, but we have to call them with arguments (if needed) to get the value from the function.&lt;/p&gt;

&lt;p&gt;For calling.&lt;br&gt;
1) we write the function's name&lt;br&gt;
2)parenthesis "()"&lt;br&gt;
3)in parenthesis, we need to write arguments(if needed)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fBmsX09n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bdhxj6fjbpgccgb8z3vd.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fBmsX09n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bdhxj6fjbpgccgb8z3vd.jpeg" alt="Image description" width="880" height="184"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The "()" Operator Invokes the Function. If we call the function without it, JS will return the function itself&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DjNLTrtj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vpjlj7fl8d37z21lfj8k.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DjNLTrtj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vpjlj7fl8d37z21lfj8k.jpeg" alt="Image description" width="880" height="468"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Function Scope
&lt;/h2&gt;

&lt;p&gt;When we define variables inside the function (it does not matter with var, let, or const), variables are  accessible only inside the function&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--encT_wCY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8bluuslf2ktidlmdl0mt.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--encT_wCY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8bluuslf2ktidlmdl0mt.jpeg" alt="Image description" width="880" height="232"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Global variables&lt;/strong&gt;&lt;br&gt;
Variables that are defined outside of any function become global and can be accessed by any function &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WhCR2W4L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h11sg5rjayyiti67tis0.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WhCR2W4L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h11sg5rjayyiti67tis0.jpeg" alt="Image description" width="880" height="248"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Function arguments&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Function arguments can be used inside the function and are local to it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Checking for variables&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Function first searches the logic values inside the function's scope and uses them. If the function does not find, it goes up from its scope and uses the first value of the particular variable.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--konMpQ49--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qxitkokfy0txgcojc6vp.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--konMpQ49--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qxitkokfy0txgcojc6vp.jpeg" alt="Image description" width="880" height="259"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Nested functions
&lt;/h2&gt;

&lt;p&gt;Functions have access to the global scope, and we can use functions to plug in other ones.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0HYVFdDA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/id29ohfqdisz04ii20fz.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0HYVFdDA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/id29ohfqdisz04ii20fz.jpeg" alt="Image description" width="880" height="473"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8T31wH8---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z3heymfrgtasyllm7oue.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8T31wH8---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z3heymfrgtasyllm7oue.jpeg" alt="Image description" width="880" height="335"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>functions</category>
      <category>javascript</category>
      <category>nestedfunction</category>
      <category>definingfunctions</category>
    </item>
    <item>
      <title>Variables in JavaScript</title>
      <dc:creator>Taguhi Manukyan</dc:creator>
      <pubDate>Mon, 07 Nov 2022 12:51:36 +0000</pubDate>
      <link>https://dev.to/taguhi_manukyan_73ffa9e44/variables-in-javascript-32ce</link>
      <guid>https://dev.to/taguhi_manukyan_73ffa9e44/variables-in-javascript-32ce</guid>
      <description>&lt;p&gt;How does the program remember things? To catch and hold the values JavaScript provides thing called a variable. Variables are containers for storing data&lt;br&gt;
There are 3 types of variables&lt;br&gt;
1) var&lt;br&gt;
2) let&lt;br&gt;
3) const&lt;/p&gt;

&lt;h2&gt;
  
  
  Short reflection on history
&lt;/h2&gt;

&lt;p&gt;Brendan Eich invented JavaScript in 1995, and at that time, there was just the variable 'var,' but in 2015,  they added 'let' and 'const' to the collection. &lt;br&gt;
Variable 'var' mainly is not used. However, if you want to run your code in older browsers, you must use 'var.'&lt;/p&gt;

&lt;h2&gt;
  
  
  Declaration of variales
&lt;/h2&gt;

&lt;p&gt;The particular word (var, let, or const) indicates that this sentence will define a variable.&lt;br&gt;
The variable's name follows it, and if we want to immediately give it a value, by an = operator and an expression.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iFsYxLws--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c3v693x8fjyb2yvjmu9w.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iFsYxLws--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c3v693x8fjyb2yvjmu9w.jpeg" alt="Image description" width="750" height="362"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Rules for naming variables
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Do&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;1)Names can contain letters, digits, underscores, and dollar signs.&lt;/p&gt;

&lt;p&gt;2)Names must begin with a letter.&lt;/p&gt;

&lt;p&gt;3)Names can also begin with '$' and '_.'&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Don't Do&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;1)Words with a special meaning, such as var, are keywords and cannot be used as variable names. JS reserves several words for use. At the bottom are some parts of that list.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CD-AgljB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sr0hidnsfo88lasdt24k.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CD-AgljB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sr0hidnsfo88lasdt24k.jpeg" alt="Image description" width="750" height="1334"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2) Names are case sensitive, and the capital letter 'A' is not the same as a lowercase 'a'.&lt;/p&gt;

&lt;h2&gt;
  
  
  Const
&lt;/h2&gt;

&lt;p&gt;Const is type of variable which CANNOT&lt;br&gt;
1)reassighned&lt;br&gt;
2)redeclared&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PwSD41vo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9lu5cjyn7uofitl7xasm.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PwSD41vo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9lu5cjyn7uofitl7xasm.jpeg" alt="Image description" width="880" height="452"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;this will be ERROR, because a is a constant and we want to reasighn it.&lt;/p&gt;

&lt;p&gt;But we can change some properties of an object or add new ones. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NdHINTuG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vb64e6k5cwij6h7klswu.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NdHINTuG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vb64e6k5cwij6h7klswu.jpeg" alt="Image description" width="880" height="421"&gt;&lt;/a&gt;&lt;br&gt;
Note: push adds new elements to an array&lt;br&gt;
program will print[1,2,3,4,5]&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AT-RAAmb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jisvsymvzddwh7ega7dg.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AT-RAAmb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jisvsymvzddwh7ega7dg.jpeg" alt="Image description" width="880" height="367"&gt;&lt;/a&gt;&lt;br&gt;
This will be an ERROR, because we want to reasighn new vale to the object&lt;/p&gt;

&lt;h2&gt;
  
  
  Var and Let
&lt;/h2&gt;

&lt;p&gt;We can classify these two variables together, separate from const, because they are similar. We can reassign the object. But they have two differences&lt;/p&gt;

&lt;p&gt;1)'var' can be redeclared, and program will consider as valid value the last declaration&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MsvWm2VH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a9c5degvjhce5m52s3bi.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MsvWm2VH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a9c5degvjhce5m52s3bi.jpeg" alt="Image description" width="880" height="492"&gt;&lt;/a&gt;&lt;br&gt;
program will print 6&lt;/p&gt;

&lt;p&gt;but 'let' cannot be declared twice &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LmSjoyA6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m44mj92c39slp88mubv0.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LmSjoyA6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m44mj92c39slp88mubv0.jpeg" alt="Image description" width="880" height="349"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;program will print ERROR as a is already declared&lt;/p&gt;

&lt;p&gt;2)'let' allows you to declare variables that are limited in scope to the block, statement, or expression on which it is used. This is unlike the 'var' keyword, which defines a variable globally, or locally to an entire function regardless of block scope.&lt;/p&gt;

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

&lt;p&gt;The scope is the space where the values of our variables are visible. In the above, we discussed the difference between 'var' and 'let.' They work in different amounts of scopes.&lt;br&gt;
If variables let and const are declared in some scope, they are visible in subscopes of that scope. Variable var is visible everywhere with its last declared value.&lt;br&gt;
If the program does not see the variable in a particular scope, it goes up and takes the latest declared value.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jL0vEjfO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hiunk5o980jy2rz712tc.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jL0vEjfO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hiunk5o980jy2rz712tc.jpeg" alt="Image description" width="880" height="386"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--t93ZJNvX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/50tpqkhgxiqnwvf6j9yz.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--t93ZJNvX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/50tpqkhgxiqnwvf6j9yz.jpeg" alt="Image description" width="880" height="349"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Qa1IK2mA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v0irujg30xeiiqo9trf6.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Qa1IK2mA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v0irujg30xeiiqo9trf6.jpeg" alt="Image description" width="880" height="693"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8Cgicf3M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xo32hge1nbhx4hqbhcyp.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8Cgicf3M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xo32hge1nbhx4hqbhcyp.jpeg" alt="Image description" width="880" height="666"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YzPptiXd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4w3kifa1fgm8ncbr5nx7.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YzPptiXd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4w3kifa1fgm8ncbr5nx7.jpeg" alt="Image description" width="880" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HoIerT3h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7zw4kg4wy4ie11tb9m6p.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HoIerT3h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7zw4kg4wy4ie11tb9m6p.jpeg" alt="Image description" width="880" height="531"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HVbd64TP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s3ii2oir0tmqdf40d0to.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HVbd64TP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s3ii2oir0tmqdf40d0to.jpeg" alt="Image description" width="880" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>variables</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Binary representation of numbers</title>
      <dc:creator>Taguhi Manukyan</dc:creator>
      <pubDate>Thu, 15 Sep 2022 17:24:10 +0000</pubDate>
      <link>https://dev.to/taguhi_manukyan_73ffa9e44/binary-representation-of-numbers-2c8m</link>
      <guid>https://dev.to/taguhi_manukyan_73ffa9e44/binary-representation-of-numbers-2c8m</guid>
      <description>&lt;h2&gt;
  
  
  Introduction to Binary
&lt;/h2&gt;

&lt;p&gt;What will be equal to 2+5? You will obviously answer 7, but everything is relative and I will ask you the same question after you read this article.&lt;br&gt;
 There are many ways of communication, for example, the Morse alphabet, the Braille alphabet etc. Binary is a means of communication of people with computers.&lt;br&gt;
 In binary, we use two digits 0 and 1. With these two digits, we can represent all numbers, letters, sound waves, etc.&lt;br&gt;
 You will think, why do we have to do that? if we already have a standard 10-digit representation of numbers. The case is in computers. Computers use voltage to understand information; as voltage has two states on(1) and off(0), we use a two-state system.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zWOLy8zY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xwg4t9flir5hiqqs8gvg.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zWOLy8zY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xwg4t9flir5hiqqs8gvg.jpg" alt="Image description" width="750" height="529"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lhJVDJIG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yka0isfmffkfsvoho7h8.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lhJVDJIG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yka0isfmffkfsvoho7h8.jpg" alt="Image description" width="750" height="538"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Converting 10-base numbers to binary
&lt;/h2&gt;

&lt;p&gt;Now the most interesting part!!! How we can convert 10-base numbers to 2-based?&lt;/p&gt;

&lt;p&gt;We have to &lt;br&gt;
1) divide the number by 2.&lt;br&gt;
2) store the remainder.&lt;br&gt;
3) divide by 2 the quotient of division.&lt;br&gt;
4) continue the same until the quotient is 0.&lt;br&gt;
5) then you have to take all remainders from bottom to top.&lt;br&gt;
Exemples:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_WAGKa-5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ax0dstgcdp69i6v5ca7.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_WAGKa-5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ax0dstgcdp69i6v5ca7.jpg" alt="Image description" width="750" height="799"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HwU9kknL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b21c1pk4ftlivnvoyyq0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HwU9kknL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b21c1pk4ftlivnvoyyq0.jpg" alt="Image description" width="750" height="742"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;OR&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We can &lt;br&gt;
1) take powers of 2 and write them after each other&lt;br&gt;
2)understand which power of 2 is the greatest power which is smaller than the number.&lt;br&gt;
3) write 1 under that power of 2&lt;br&gt;
4) subtract that power of 2 from the number&lt;br&gt;
5)repeat this until the number is 0 &lt;br&gt;
6) write 0s under the powers of 2 which are not used.&lt;br&gt;
7) start to write numbers from left to right from the first 1.&lt;br&gt;
Examples:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HAiyd2YD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vh9jsz8kttybucl5brgj.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HAiyd2YD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vh9jsz8kttybucl5brgj.jpg" alt="Image description" width="750" height="894"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Rsl3ry-y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gxjega2y1utq2un008fd.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Rsl3ry-y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gxjega2y1utq2un008fd.jpg" alt="Image description" width="750" height="1027"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Converting Binary to decimal
&lt;/h2&gt;

&lt;p&gt;For converting binary to ordinary numbers we have to &lt;br&gt;
1) write indexes of all digits of binary&lt;br&gt;
2) raise 2 to the power of a particular index&lt;br&gt;
3) multiply it by 1 or 0.&lt;br&gt;
4) add them together&lt;br&gt;
Example:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--V1JvFdDD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1swhzrh0pmbx6zt4d14u.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--V1JvFdDD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1swhzrh0pmbx6zt4d14u.jpg" alt="Image description" width="750" height="919"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5y0kg-4z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z5m5tau1wsutis3r62yh.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5y0kg-4z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z5m5tau1wsutis3r62yh.jpg" alt="Image description" width="750" height="837"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Addition of binary  numbers
&lt;/h2&gt;

&lt;p&gt;We do the addition of binary numbers as the ordinary addition for 10-based numbers.&lt;br&gt;
1) we write numbers under each other&lt;br&gt;
2) add digits from the same column together&lt;br&gt;
3) if the sum of digits is greater than 1 we carry the whole part to the next left column.&lt;br&gt;
Examples:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Fo3Ak0aF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7fiu8dr1egv96jewu594.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Fo3Ak0aF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7fiu8dr1egv96jewu594.jpg" alt="Image description" width="749" height="752"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uGhhrhtO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0483bwei1oad3nidd9nk.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uGhhrhtO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0483bwei1oad3nidd9nk.jpg" alt="Image description" width="750" height="680"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;NOTE: &lt;br&gt;
0+0 =0&lt;br&gt;
1+0 = 1&lt;br&gt;
0+1 = 1&lt;br&gt;
1+1 = 0 and carry 1 to the next column&lt;br&gt;
1+1+1 = 1 and carry 1 to the next column&lt;/p&gt;

&lt;h2&gt;
  
  
  Subtraction of binary numbers
&lt;/h2&gt;

&lt;p&gt;For subtraction&lt;br&gt;
1) We have to write numbers under each other&lt;br&gt;
2)subtract digits from the same column&lt;br&gt;
3) if the digit written first is smaller than the second we have to borrow 1 digit from the left column.&lt;br&gt;
Examples:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LTL6Fesx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/062tjugkavsdvu2g2glf.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LTL6Fesx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/062tjugkavsdvu2g2glf.jpeg" alt="Image description" width="750" height="1334"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ttMDsOMi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kyxirm9eyd95k3cwnz4f.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ttMDsOMi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kyxirm9eyd95k3cwnz4f.jpg" alt="Image description" width="750" height="1334"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;NOTE:&lt;br&gt;
1-1 = 0&lt;br&gt;
0-0 = 0&lt;br&gt;
1-0 = 1&lt;br&gt;
0-1 = 10(with borrow)- 1 = 1&lt;/p&gt;

&lt;h2&gt;
  
  
  Multiplication of binary numbers
&lt;/h2&gt;

&lt;p&gt;We do multiplication also as we do it for decimal numbers.&lt;br&gt;
1)write numbers under each other&lt;br&gt;
2)multiply each digit from the second number by the first number&lt;br&gt;
3)add the numbers from the same column together.&lt;br&gt;
Examples:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3zybJYi---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2jte2fhvzy3alowlu55d.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3zybJYi---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2jte2fhvzy3alowlu55d.jpg" alt="Image description" width="750" height="819"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0dMP6OUI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hvvrh40gnzz2sf36vkjw.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0dMP6OUI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hvvrh40gnzz2sf36vkjw.jpg" alt="Image description" width="750" height="1040"&gt;&lt;/a&gt;&lt;br&gt;
NOTE:&lt;br&gt;
1*number = number&lt;br&gt;
0*number = 0&lt;/p&gt;

&lt;h2&gt;
  
  
  Division of binary numbers
&lt;/h2&gt;

&lt;p&gt;1)We have to take 1st digit of the number and divide it by the 2nd number&lt;br&gt;
2) If the number which we want to divide is less than the second one we have to write 0&lt;br&gt;
3)otherwise we have to write 1&lt;br&gt;
4)Then we have to subtract the second number * 1 or 2 from the first number's digits &lt;br&gt;
5) add another digit of the first number.&lt;br&gt;
6)continue until you use all digits of the first number.&lt;br&gt;
Examples:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gdrybdkq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h0xdpiaguxn1qnke2brs.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gdrybdkq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h0xdpiaguxn1qnke2brs.jpg" alt="Image description" width="750" height="1334"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4KR4Bwoa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wk7udmgxj47juifdtw28.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4KR4Bwoa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wk7udmgxj47juifdtw28.jpg" alt="Image description" width="750" height="1334"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Soooooo, what will be equal to 2+5? ;))&lt;/p&gt;

</description>
      <category>binary</category>
      <category>numbers</category>
      <category>representation</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
