<?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: Aravindan07</title>
    <description>The latest articles on DEV Community by Aravindan07 (@aravindan07).</description>
    <link>https://dev.to/aravindan07</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%2F416640%2Fa7c67a2b-7941-446e-b833-87e49e73996b.jpeg</url>
      <title>DEV Community: Aravindan07</title>
      <link>https://dev.to/aravindan07</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aravindan07"/>
    <language>en</language>
    <item>
      <title>Introduction to Javascript Universe part - 2</title>
      <dc:creator>Aravindan07</dc:creator>
      <pubDate>Sat, 12 Dec 2020 18:04:15 +0000</pubDate>
      <link>https://dev.to/aravindan07/introduction-to-javascript-universe-part-2-1o1h</link>
      <guid>https://dev.to/aravindan07/introduction-to-javascript-universe-part-2-1o1h</guid>
      <description>&lt;h3&gt;
  
  
  Recap of the last post
&lt;/h3&gt;

&lt;p&gt;In the first part of the series, we saw about &lt;a href="https://dev.to/aravindan07/introduction-to-javascript-universe-3h"&gt;&lt;strong&gt;values and variables in JS&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Points to be remembered,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;There are a total of 9 types of values in JS, categorized into &lt;br&gt;
primitive values, and objects &amp;amp; functions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Primitive values contain Undefined, Null, Numbers, Strings, &lt;br&gt;
BigInts and Symbol.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Apart from the above types everything else is objects. e.g., &lt;br&gt;
&lt;em&gt;Arrays&lt;/em&gt;, &lt;em&gt;Date&lt;/em&gt;, &lt;em&gt;regular expressions&lt;/em&gt; come under &lt;strong&gt;objects&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Primitive values are immutable (cannot be modified).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Objects and functions are mutable (can be changed).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A variable must represent a value it can hold any value from &lt;br&gt;
the above types.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this post, we are gonna concentrate on &lt;strong&gt;objects&lt;/strong&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Introduction to Objects
&lt;/h4&gt;

&lt;p&gt;Arrays, Dates, regular expressions, and other non-primitive values come under objects.&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;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="k"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;({}));&lt;/span&gt; &lt;span class="c1"&gt;// "object"&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="k"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;([]));&lt;/span&gt; &lt;span class="c1"&gt;// "object"&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="k"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;()));&lt;/span&gt; &lt;span class="c1"&gt;// "object"&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="k"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// "object"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We know that objects are non-primitive values which means that by default &lt;em&gt;objects are mutable&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;To create an object we need to use the { } object literal, &lt;em&gt;which creates a brand new object value&lt;/em&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;let&lt;/span&gt; &lt;span class="nx"&gt;newObj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;anotherObj&lt;/span&gt; &lt;span class="o"&gt;=&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="k"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newObj&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;anotherObj&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// object object&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code, &lt;em&gt;newObj and anotherObj&lt;/em&gt; are &lt;strong&gt;objects&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A diagrammatic representation of the above two variables will look like the below diagram.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6T7uTsAI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/01zo619ah4zet5e745vm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6T7uTsAI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/01zo619ah4zet5e745vm.png" alt="object creation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the above diagram, we can conclude that each of the two variables will have a brand new object value.&lt;/p&gt;

&lt;h4&gt;
  
  
  Properties in objects
&lt;/h4&gt;

&lt;p&gt;An object contains properties that are basically key-value pairs.&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;let&lt;/span&gt; &lt;span class="nx"&gt;objectWithProperty&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="na"&gt;propertyOne&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;This is property one&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="na"&gt;propertyTwo&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;This is property two&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;propertyOne and propertyTwo are called &lt;em&gt;keys&lt;/em&gt;. "This is property one" and "This is property two" are called &lt;em&gt;values&lt;/em&gt;. A value can be of any type in this example I have a value in the &lt;em&gt;string type&lt;/em&gt; but you can store literally any type of value in the values field.&lt;/p&gt;

&lt;p&gt;To access the properties of an object we use either dot(.) notation or bracket ([ ]) notation.&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;let&lt;/span&gt; &lt;span class="nx"&gt;objectWithProperties&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;propertyOne&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;This is property one&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;propertyTwo&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;This is property two&lt;/span&gt;&lt;span class="dl"&gt;"&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;objectWithProperties&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;propertyOne&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// "This is property one" using dot notation&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;objectWithProperties&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;propertyTwo&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt; &lt;span class="c1"&gt;// "This is property two" using bracket notation&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A diagrammatic illustration of the above code looks like this,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--R9m2k-5H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/42hgtc50o425rq9wi1li.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--R9m2k-5H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/42hgtc50o425rq9wi1li.png" alt="Illustration of the above code"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Properties have names. A single object can’t have two properties with the same name.&lt;br&gt;
For example, let's say we have a property called &lt;em&gt;name&lt;/em&gt; in an object. We can't declare another property with the same property name '&lt;em&gt;name&lt;/em&gt;' in the same object.&lt;/p&gt;

&lt;p&gt;If we try to do it, then Javascript will take the last key-value pair and neglects the previous key-value pairs of the same names.&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;let&lt;/span&gt; &lt;span class="nx"&gt;person&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;Anne&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;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;Hathway&lt;/span&gt;&lt;span class="dl"&gt;"&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;person&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// {age: 32, name: "Hathway"} 1st name property is neglected&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;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// "Hathway" not "Anne"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code snippet, the first name property is neglected and the last name property is taken.&lt;/p&gt;

&lt;p&gt;The property names are always case-sensitive in Javascript. For example, name and Name would be two completely different properties from JavaScript’s point of view.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If we don’t know a property name ahead of time but we have it in code as a string value, we can use the [] “bracket notation” to read it from an object.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What about missing properties?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;If we try to access the properties which are not defined in an object it will not throw an error instead it will return undefined as a value.&lt;/strong&gt;&lt;br&gt;
Example:&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;let&lt;/span&gt; &lt;span class="nx"&gt;person&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;Anne Hathway&lt;/span&gt;&lt;span class="dl"&gt;"&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;person&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="c1"&gt;// undefined&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Javascript follows certain steps while dealing with objects.&lt;/strong&gt; They are: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Figure out the value of the part before the dot (.).&lt;/li&gt;
&lt;li&gt;If that value is null or undefined, throw an error immediately.&lt;/li&gt;
&lt;li&gt;Check whether a property with that name exists in our object.&lt;/li&gt;
&lt;li&gt;If it exists, answer with the value this property points to.&lt;/li&gt;
&lt;li&gt;If it doesn’t exist, answer with the undefined value.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now consider the below code snippet,&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;let&lt;/span&gt; &lt;span class="nx"&gt;person&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;Anne Hathway&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&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;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;address&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;city&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// ?&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What will be the output of the above code snippet?&lt;/p&gt;

&lt;p&gt;If you thought that the answer would be an error, you are right.&lt;/p&gt;

&lt;p&gt;But, How? Read rules 1 and 2, &lt;em&gt;if the left side of the dot operator is null or undefined it will throw an error.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I hope I had given enough details about &lt;strong&gt;objects in Javascript Universe.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you want to know more about objects read the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object"&gt;MDN&lt;/a&gt; docs.&lt;/p&gt;

&lt;p&gt;If you like the content connect with me on &lt;a href="https://www.linkedin.com/in/aravindan33/"&gt;Linkedin&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;See you all in my next post. Have a good day!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>codenewbie</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Introduction to Javascript universe</title>
      <dc:creator>Aravindan07</dc:creator>
      <pubDate>Fri, 11 Dec 2020 09:23:16 +0000</pubDate>
      <link>https://dev.to/aravindan07/introduction-to-javascript-universe-3h</link>
      <guid>https://dev.to/aravindan07/introduction-to-javascript-universe-3h</guid>
      <description>&lt;h2&gt;
  
  
  Introduction to Javascript
&lt;/h2&gt;

&lt;p&gt;JavaScript is a lightweight, interpreted, object-oriented language and is best known as the scripting language for Web pages. Apart from this Javascript can also be used in non-browser environments. Thanks to NodeJs.&lt;br&gt;
If you don't understand the above definitions bear with me till the end you'll understand everything.&lt;br&gt;
In this post, we are going to concentrate only on the two most important and fundamental concepts - &lt;strong&gt;variables and values&lt;/strong&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Values
&lt;/h2&gt;

&lt;p&gt;In Javascript, not only numbers are values but also a few other things like objects and functions. Wait, what?! Did you just say objects and functions are values?&lt;/p&gt;

&lt;p&gt;Yep! Objects and functions also hold some value in Javascript.&lt;/p&gt;
&lt;h3&gt;
  
  
  Types of values
&lt;/h3&gt;

&lt;p&gt;After years of research by Javascript enthusiasts and computer engineers, they have found only &lt;strong&gt;9 types of values in Javascript&lt;/strong&gt; everything other than these 9 types is &lt;em&gt;Objects&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;What are those 9 types?&lt;/p&gt;

&lt;p&gt;These 9 types of values are classified into two types, &lt;strong&gt;Primitive data values, Objects &amp;amp; functions&lt;/strong&gt;. &lt;/p&gt;
&lt;h3&gt;
  
  
  Primitive Values
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Undefined (undefined)&lt;/strong&gt; - used for unintentionally missing values.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Null (null)&lt;/strong&gt; - used for intentionally missing values.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Booleans (true and false)&lt;/strong&gt; - used for logical operations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Numbers (10,-20,etc)&lt;/strong&gt; - used for math calculations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Strings ("xyz","Hello world",etc)&lt;/strong&gt; - used for text inputs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Symbols&lt;/strong&gt; - used to hide implementation details.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;BigInts&lt;/strong&gt; - used for math on big numbers.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Objects and Functions
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Objects ( {} )&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Functions ( () )&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Apart from these everything else is an object. E.g Arrays, Date, Regular expressions are all &lt;em&gt;Objects&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Consider the below examples&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;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="k"&gt;typeof&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="k"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&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="k"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/Hello World/&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Try it in your console and I am sure that you will get an &lt;em&gt;object&lt;/em&gt; as a result.&lt;/p&gt;

&lt;p&gt;I hope you are clear now. But also remember that primitive values are not objects everything other than that is &lt;em&gt;objects&lt;/em&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Expressions
&lt;/h4&gt;

&lt;p&gt;Expressions are questions that JavaScript can answer. JavaScript answers expressions with &lt;strong&gt;values&lt;/strong&gt; not with any other types like objects and functions.&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;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="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 4 which is a value&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is enough about expressions now But surely there are a lot more things to do with expressions.&lt;/p&gt;

&lt;h4&gt;
  
  
  Primitive values are immutable
&lt;/h4&gt;

&lt;p&gt;Wait, what?! Yeah, you read it correctly we cannot change the value of primitive values.&lt;/p&gt;

&lt;p&gt;Consider the code snippet below&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;let&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Test&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;test&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;R&lt;/span&gt;&lt;span class="dl"&gt;"&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;test&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What will be the output of your program?&lt;/p&gt;

&lt;p&gt;If you are in a strict mode this might throw an error otherwise the output will be &lt;em&gt;Test&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wdxFpaJo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0svmqu8lvaunnkznx6ep.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wdxFpaJo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0svmqu8lvaunnkznx6ep.png" alt="output of code snippet"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Look at the error when we use "use strict",&lt;em&gt;it says cannot modify read-only property of string&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;I have taken the example of a string here, you can take any primitive values and try to modify them, it will either throw an error or it returns an unmodified value depends upon whether you are in strict mode or not.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Takeaway&lt;/strong&gt;: Primitive values are immutable(cannot be changed).&lt;/p&gt;

&lt;p&gt;Now consider the code snippet below&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;let&lt;/span&gt; &lt;span class="nx"&gt;numberTen&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="nx"&gt;numberTen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Ten&lt;/span&gt;&lt;span class="dl"&gt;"&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;numberTen&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//what will be the output?&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you guessed the output as &lt;em&gt;10&lt;/em&gt; or &lt;em&gt;error&lt;/em&gt; you are wrong. The output will be &lt;em&gt;Ten&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Now a question might arise in your mind, that primitive values are immutable but why the above line changed the values.&lt;/p&gt;

&lt;p&gt;To answer that question look at the above code snippet once again.&lt;br&gt;
&lt;strong&gt;We never changed the value of 10 we only changed the value of variable numberTen.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Takeaway&lt;/strong&gt;: Variables are not values. variables point to values and thus we can control where we need to point the variable.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lAPTOCFv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9gkqtj7mfqkwun0vwg6g.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lAPTOCFv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9gkqtj7mfqkwun0vwg6g.gif" alt="explanation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above GIF explains what happens under the hood.&lt;/p&gt;

&lt;p&gt;Now let's see the types of values one by one. We will start with the &lt;em&gt;Undefined&lt;/em&gt;.&lt;/p&gt;
&lt;h4&gt;
  
  
  Undefined
&lt;/h4&gt;

&lt;p&gt;There is only one value in type Undefined which is undefined.&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;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="k"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// "undefined"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It’s called undefined so you might think it’s not there — but it is a value and a very real one!&lt;/p&gt;

&lt;p&gt;In JavaScript, it represents the concept of an &lt;strong&gt;unintentionally missing value&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;We can assign a variable undefined like how we assign other values like 10, "Hello" to the variable.&lt;/p&gt;

&lt;p&gt;undefined commonly occurs in a scenario like where we defined a variable but didn't get assigned to any value.&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;var&lt;/span&gt; &lt;span class="nx"&gt;getUndefined&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;getUndefined&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// "undefined"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also, you cannot read a property from undefined as you do it in objects, strings, and arrays.&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;var&lt;/span&gt; &lt;span class="nx"&gt;car&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;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;noOfWheels&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Uncaught TypeError: Cannot read property 'noOfWheels' of undefined&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;undefined is a regular primitive value, like 10 or "hello". &lt;em&gt;Handle it with care&lt;/em&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Null
&lt;/h4&gt;

&lt;p&gt;Null behaves almost similar to undefined. There is only one value for type Null which is &lt;em&gt;null&lt;/em&gt;. null is used for intentionally missing values.&lt;/p&gt;

&lt;p&gt;Like undefined in null also if you try to access properties it will throw an error.&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;let&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&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;test&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;marks&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Uncaught TypeError: Cannot read property 'marks' of null&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, if you try to get the type of null using the &lt;em&gt;typeof&lt;/em&gt; operator you won't get &lt;em&gt;null&lt;/em&gt; as a type you will get &lt;em&gt;object&lt;/em&gt; as a type.&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;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="k"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// "object"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Don't worry about this behavior, it is because of a bug in javascript which cannot be fixed. Unfortunately, we have to live with this bug forever.&lt;br&gt;
It is a primitive value, and it doesn’t behave in any way like an object.&lt;/p&gt;
&lt;h4&gt;
  
  
  Booleans
&lt;/h4&gt;

&lt;p&gt;There are only two values for the Boolean type which are &lt;strong&gt;true and false&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Boolean values are used to perform logical operations.&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;var&lt;/span&gt; &lt;span class="nx"&gt;isTrue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;isFalse&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;oppTrue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;isTrue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;oppFalse&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;isfalse&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;isTrue&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;oppFalse&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// true&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;isTrue&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;oppTrue&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it for booleans it is simply used to perform &lt;em&gt;logical&lt;/em&gt; operations. And like null and undefined if we try to access the properties it will throw an error.&lt;/p&gt;

&lt;h4&gt;
  
  
  Numbers
&lt;/h4&gt;

&lt;p&gt;Numbers in javascript are quite interesting. Javascript numbers don't behave exactly as regular mathematical numbers.&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;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="mf"&gt;0.1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.2&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mf"&gt;0.3&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// false&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="mf"&gt;0.1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.2&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mf"&gt;0.30000000000000004&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is because javascript doesn't follow regular maths it follows &lt;em&gt;floating point math&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Floating-point math is similar. In real math, there is an infinite set of numbers. But in floating-point math, there is only 18 quintillion of them. So when we write numbers in our code or do calculations with them, JavaScript picks the closest numbers that it knows about — just like our scanner does with colors.&lt;/p&gt;

&lt;p&gt;You can learn more about floating-point math &lt;a href="https://0.30000000000000004.com/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;There are special numbers in Javascript which are Infinity,-Infinity, NaN, and -0.&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;let&lt;/span&gt; &lt;span class="nx"&gt;zero&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nx"&gt;zero&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Infinity&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nx"&gt;zero&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// NaN&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// -Infinity&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// -0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's look at NaN,&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;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="k"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;NaN&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// "number"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From a JavaScript perspective, NaN is a numeric value. It is not null, undefined, a string, or some other type. But in floating-point math, the name for that term is “not a number”. So it is a numeric value. It happens to be called “not a number” because it represents an invalid result.&lt;br&gt;
Be careful with special numbers, they might come up due to a coding mistake.&lt;/p&gt;
&lt;h4&gt;
  
  
  Strings
&lt;/h4&gt;

&lt;p&gt;Strings are text in javascript. We can write a string in three ways in javascript.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;single quotes('').&lt;/li&gt;
&lt;li&gt;double quotes("").&lt;/li&gt;
&lt;li&gt;backticks.
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&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="k"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// "string"&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="k"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;text&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// "string"&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="k"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`text`&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// "string"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Strings have a few built-in properties which we can access.&lt;br&gt;
e.g&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;let&lt;/span&gt; &lt;span class="nx"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text&lt;/span&gt;&lt;span class="dl"&gt;"&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;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;concat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// "textstring"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can get to know more about the string built-in properties &lt;a href="https://www.w3schools.com/jsref/jsref_obj_string.asp"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  BigInts
&lt;/h4&gt;

&lt;p&gt;Regular numbers can’t represent large integers with precision, that's why BigInts are added to the javascript language.&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;let&lt;/span&gt; &lt;span class="nx"&gt;bigNumber&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;9007199254740991&lt;/span&gt;&lt;span class="nx"&gt;n&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;bigNumber&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 9007199254740992n&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;bigNumber&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 9007199254740993n&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;bigNumber&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 9007199254740994n&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;bigNumber&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 9007199254740995n&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;bigNumber&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 9007199254740996n&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice n at the end, BigInts are represented using the leading n at the end.&lt;br&gt;
BigInts are great for financial calculations, where precision is crucial. However, calculations made with larger numbers take more time and resources hence use them wisely.&lt;/p&gt;

&lt;p&gt;That's it for this post there are some concepts we need to cover that we will cover in the next post.&lt;/p&gt;

&lt;p&gt;If you read this completely please give me some suggestions.&lt;/p&gt;

&lt;p&gt;Some of the points are taken from the &lt;em&gt;Just Javascript series&lt;/em&gt; by Dan Abramov. I am writing this post from what I understood from that series. &lt;/p&gt;

&lt;p&gt;If you like this post do follow me so that you won't miss anything. &lt;strong&gt;Thanks for reading&lt;/strong&gt;!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>css</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Introduction to styled-components Part-1</title>
      <dc:creator>Aravindan07</dc:creator>
      <pubDate>Thu, 03 Dec 2020 11:27:27 +0000</pubDate>
      <link>https://dev.to/aravindan07/introduction-to-styled-components-part-1-2j66</link>
      <guid>https://dev.to/aravindan07/introduction-to-styled-components-part-1-2j66</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_xhjUcwv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/sjkizkzbephcwf87l0ru.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_xhjUcwv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/sjkizkzbephcwf87l0ru.png" alt="bdacfa80-6132-11e9-90b9-33e6eee04d1f"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why styled-components?
&lt;/h2&gt;

&lt;p&gt;I know what you are thinking right now I know bootstrap, sass, etc., and why the hell should I use styled-components. Bear with me till the end I am sure you are gonna love this awesome library.&lt;/p&gt;

&lt;p&gt;Styled-components is one of the popular styling libraries for React.js and it is used by some of the tech giants like Google, Github, Spotify, Tinder, etc.,&lt;/p&gt;

&lt;p&gt;The reason behind the popularity of styled-components is because of the &lt;strong&gt;React way of styling&lt;/strong&gt;(component-based styling) i.e we can create a component by using CSS in JS and we can use it anywhere in the application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;Installation is super simple,&lt;br&gt;
Install styled-components from your preferred package managers(npm or yarn).&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install -styled-components --save&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Advantages of using styled-components
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Automatic critical CSS.&lt;/li&gt;
&lt;li&gt;No class name bugs.&lt;/li&gt;
&lt;li&gt;Easier detection of CSS.&lt;/li&gt;
&lt;li&gt;Simple dynamic styling.&lt;/li&gt;
&lt;li&gt;Painless maintenance.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Getting started
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Create a react application by using create-react-app.&lt;/li&gt;
&lt;li&gt;Install styled-components using npm or yarn
&lt;code&gt;npm install styled-components --save&lt;/code&gt; or &lt;code&gt;yarn add styled-components&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;After the above steps you can see that in your package.json file as a dependency.
Your package.json looks like this :
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"dependencies": {
"@testing-library/jest-dom": "^5.11.6",
    "@testing-library/react": "^11.2.2",
    "@testing-library/user-event": "^12.4.0",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-scripts": "4.0.1",
    "styled-components": "^5.2.1",
    "web-vitals": "^0.2.4"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Creating our first styled-component
&lt;/h2&gt;

&lt;p&gt;Now we have all the prerequisites to style our react app using styled-components.&lt;/p&gt;

&lt;p&gt;Trust me it's simple and awesome!&lt;/p&gt;

&lt;p&gt;In app.js add these lines of code&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Lu0P9Q1V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/itpzgjqfpaazce9vpotk.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Lu0P9Q1V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/itpzgjqfpaazce9vpotk.jpg" alt="Hello world"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The lines with white dots or white lines are the newly added lines in the app.js file.&lt;/p&gt;

&lt;p&gt;Now let's understand what we have written in this file.&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;styled&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;styled-components&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;In the above line, I have just imported the styled-components library as a default import named &lt;em&gt;styled&lt;/em&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;FirstButton&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;styled&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="s2"&gt;`
  border: none;
  outline: none;
  padding: 10px;
  background: #15b996;
  border-radius: 5px;
  color: #ffffff;
  display: block;
  margin: 200px auto 0 auto;
  height: 50px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this snippet, I have created a variable named FirstButton and used the styled-components library to create a Button component.&lt;/p&gt;

&lt;p&gt;But where we define that we are going to create a button?&lt;/p&gt;

&lt;p&gt;Look carefully in the first line of the FirstButton variable we have defined something like this&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;FirstButton&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;styled&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;button&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;We have called the &lt;code&gt;button&lt;/code&gt; object from the &lt;code&gt;styled&lt;/code&gt; object as &lt;code&gt;styled.button&lt;/code&gt; and that's how we defined that we are going to create a button component.&lt;/p&gt;

&lt;p&gt;Note that after &lt;code&gt;styled.button&lt;/code&gt; we used backticks(``) to write CSS inside the FirstButton variable. This is needed because we are writing CSS in JS and not CSS. Because styled-components utilize tagged template literals to style your components.&lt;/p&gt;

&lt;p&gt;After that, we use the FirstButton component like any other Component in React.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1sU4dA5K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/adl3ix2mge4uvlpw3exn.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1sU4dA5K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/adl3ix2mge4uvlpw3exn.jpg" alt="app.js"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In line 23, we used our button as a React component.&lt;/p&gt;

&lt;p&gt;That's it we have created our first styled-component.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wUm0iloL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/p66w2ks96pxh4bcbhmeo.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wUm0iloL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/p66w2ks96pxh4bcbhmeo.jpg" alt="Output"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see the output of our styled component button above.😍&lt;/p&gt;

&lt;p&gt;Using styled-components we can style any HTML element not only the button.&lt;br&gt;
For example, if you want to style a div element you can do that by replacing &lt;code&gt;styled.button&lt;/code&gt; with &lt;code&gt;styled.div&lt;/code&gt; and likewise we can style all the HTML elements.&lt;/p&gt;

&lt;p&gt;It is not possible to explain this awesome library in one post we will explore this in my upcoming posts!&lt;/p&gt;

&lt;p&gt;For more details, you can explore the official docs of &lt;a href="https://styled-components.com/"&gt;styled-components&lt;/a&gt; they have good documentation there.&lt;/p&gt;

&lt;p&gt;If you like this post do follow me for more.If you find anything wrong do let me know.&lt;/p&gt;

&lt;p&gt;Thanks for reading.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>css</category>
      <category>react</category>
    </item>
  </channel>
</rss>
