<?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: Ankita Bagale</title>
    <description>The latest articles on DEV Community by Ankita Bagale (@ankitabagale).</description>
    <link>https://dev.to/ankitabagale</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%2F521877%2Fd56767b6-379c-44c2-a7f3-eba612854162.png</url>
      <title>DEV Community: Ankita Bagale</title>
      <link>https://dev.to/ankitabagale</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ankitabagale"/>
    <language>en</language>
    <item>
      <title>JavaScript: Errors, Types, Properties</title>
      <dc:creator>Ankita Bagale</dc:creator>
      <pubDate>Sun, 21 Mar 2021 11:14:29 +0000</pubDate>
      <link>https://dev.to/ankitabagale/javascript-errors-types-properties-2cg5</link>
      <guid>https://dev.to/ankitabagale/javascript-errors-types-properties-2cg5</guid>
      <description>&lt;p&gt;In this blog, I am going to talk about types of errors in Javascript. So grab a seat, have popcorns ready.&lt;/p&gt;

&lt;p&gt;Javascript throws runtime errors and today we are going to see how to read, understand and use those errors in your code&lt;/p&gt;

&lt;h3&gt;
  
  
  Error:
&lt;/h3&gt;

&lt;p&gt;In JS, an Error is an object. It has a Class &lt;code&gt;Error&lt;/code&gt;, which has a constructor &lt;code&gt;Error()&lt;/code&gt;. This is the generic error class in JS.&lt;/p&gt;

&lt;p&gt;There are various types of errors that means there are various Classes of Errors.&lt;/p&gt;

&lt;p&gt;So we can create Error objects from such constructors. &lt;/p&gt;

&lt;p&gt;The generic constructor Error takes one argument (a message that will be used to describe the error)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//as Error is an object we can create it from its class' constructor
let newError = new Error("MyMessage for the error");
//now this newError is an instance(object) of class Error
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So yes, you are right, if it's an object and also it has a Class, it should have properties too.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Standard Properties of Error Object:&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  1. name -
&lt;/h4&gt;

&lt;p&gt;By default, Error instances are given the name "Error". All the instances of Class Error will have a name property as "Error".&lt;/p&gt;

&lt;h4&gt;
  
  
  2. message -
&lt;/h4&gt;

&lt;p&gt;The message property is a human-readable description of the error. Contains brief information of the error.&lt;/p&gt;

&lt;h4&gt;
  
  
  3. toString-
&lt;/h4&gt;

&lt;p&gt;You might be thinking we have the toString method for Objects too. But the Error object overrides the Object.prototype.toString().&lt;br&gt;
In the background, it combines the name and message and converts them into a string.&lt;/p&gt;

&lt;p&gt;These are 3 standard properties, there are other non-standard properties too but they might not be supported by some browsers.&lt;/p&gt;

&lt;p&gt;Let's check below example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(newError)
Uncaught Error: MyMessage for the error
    at &amp;lt;anonymous&amp;gt;:1:13
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;See the 1st word in the above error- &lt;code&gt;Uncaught&lt;/code&gt;: it means your error was not handled using the catch keyword.&lt;/p&gt;

&lt;p&gt;Next word is- &lt;code&gt;Error&lt;/code&gt;: It is the value of the name property of the Error.&lt;/p&gt;

&lt;p&gt;The next part is - &lt;code&gt;MyMessage for the error&lt;/code&gt;: It is the value of the message property in the Error. &lt;/p&gt;

&lt;p&gt;The next part is - &lt;code&gt;at &amp;lt;anonymous&amp;gt;:1:13&lt;/code&gt;: This is the very important part, this is a stack trace, it shows where the error occurred, will talk about this in detail in later part of the blog.&lt;/p&gt;

&lt;p&gt;So the above statement is just all the properties of Error showed together. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;toString():&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;toString method when called on Error, will return a string like - name: message&lt;/p&gt;

&lt;p&gt;If the name property value is undefined, it returns the string with name value as &lt;code&gt;Error&lt;/code&gt;&lt;br&gt;
if the message property value is undefined, it returns the string with message value as an empty string ""&lt;/p&gt;

&lt;p&gt;We will see one example of the toString() method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var error1 = new Error('Bad operation');
console.log(error1.name) //Error 
//As it is an instance of Error class
console.log(error1.message) //Bad operation
console.log(error1.toString()); // 'Error: Bad operation'

var error2 = new Error('Bad operation');
error2.name = undefined;
//assigned undefined to error2 name property
console.log(error2.toString()); // 'Error: Bad operation'
//toString will return "Error" for undefined name

var error3 = new Error('Bad operation');
error3.name = 'hello';
error3.message = undefined;
//assigned undefined to error3 message property
console.log(error3.toString()); // 'hello'
//toString will return empty string for undefined message
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Other than the generic Error constructor, there are other core error constructors in JavaScript. We will learn some of them in this blog.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. RangeError :
&lt;/h3&gt;

&lt;p&gt;The RangeError object is thrown when a value is not in the set or range of allowed values.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Constructor&lt;/strong&gt;:  RangeError()&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Properties&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;message: RangeError should provide its own message property&lt;/li&gt;
&lt;li&gt;name: by default RangeError name property has the value "RangeError".
Both the properties are inherited from the Error class
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function checkAge(n)
{
    try{
        if( !(n &amp;gt;= 18) )
        {
            throw new RangeError("Age must be greater than 18 to sign up")
        }
    }catch(error) { 
         console.error(error);
    }
}
checkAge(13)
// RangeError: Age must be greater than 18 to sign up
// at checkAge (&amp;lt;anonymous&amp;gt;:6:19)
// at &amp;lt;anonymous&amp;gt;:1:1

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. ReferenceError:
&lt;/h3&gt;

&lt;p&gt;ReferenceError object is thrown when a non-existing variable is referenced or used in your code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Constructor&lt;/strong&gt;:  ReferenceError()&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Properties&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;message: ReferenceError should provide its own message property&lt;/li&gt;
&lt;li&gt;name: by default ReferenceError name property has the value "ReferenceError".
Both the properties are inherited from the Error class
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let name="Ankita"
function printFullName( ) {
    try{
         console.log(`${name} ${surname}`);
    } catch( error ){
         console.error(error)
    }
}
printFullName( );
//ReferenceError: surname is not defined
//  at printFullName (&amp;lt;anonymous&amp;gt;:4:33)
//  at &amp;lt;anonymous&amp;gt;:9:1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. SyntaxError:
&lt;/h3&gt;

&lt;p&gt;The SyntaxError object is thrown when a program contains syntactically invalid code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Constructor&lt;/strong&gt;:  SyntaxError()&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Properties&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;message: SyntaxError should provide its own message property&lt;/li&gt;
&lt;li&gt;name: by default SyntaxError name property has the value "SyntaxError".
Both the properties are inherited from the Error class
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const printName = (){
    console.log("Ankita");
}
//Above arrow function has fat arrow missing, it will throw below error
//Uncaught SyntaxError: Unexpected token ')'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. TypeError:
&lt;/h3&gt;

&lt;p&gt;The TypeError object is thrown when an operation could not be performed, mostly when a value is not of the expected type.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Constructor&lt;/strong&gt;:  TypeError()&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Properties&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;message: TypeError should provide its own message property&lt;/li&gt;
&lt;li&gt;name: by default TypeError name property has the value "TypeError".
Both the properties are inherited from the Error class
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// This is 1st kind of TypeError, where we try to change a value that cannot be changed
const marks = 200;
const totalMarks = 250;
marks = marks * 100 / totalMarks;
//Uncaught TypeError: Assignment to constant variable.
//   at &amp;lt;anonymous&amp;gt;:1:7

//This is 2nd kind of TypeError. If an operand/argument is passed to a operator/function whose type is not compatible with the operator/function.
//below code tries to apply spread operator on a number, hence it throws an TypeError
let number = 9;
let numberSpreaded = [...number];
// Uncaught TypeError: number is not iterable
//   at &amp;lt;anonymous&amp;gt;:1:26


//This is 3rd kind of TypeError, when a value is used in an inappropriate way
//below reduce method can be called on array, but instead we are calling it on a number, it will throw an TypeError
let arr= 9;
arr.reduce((sum,num)=&amp;gt;sum+num, 0);
// Uncaught TypeError: arr.reduce is not a function
//    at &amp;lt;anonymous&amp;gt;:2:5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. URIError:
&lt;/h3&gt;

&lt;p&gt;URIError is thrown when a global URI method is used in a wrong way.&lt;/p&gt;

&lt;p&gt;e.g. The decodeURI() function takes encoded URI as an argument, it throws an URIError when the encoded URI contains invalid character sequences.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Constructor&lt;/strong&gt;:  URIError()&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Properties&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;message: URIError should provide its own message property&lt;/li&gt;
&lt;li&gt;name: by default URIError name property has the value "URIError".
Both the properties are inherited from the Error class
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;try {
  let a = decodeURI('%AN%KI%');
} catch(e) {
  console.error(e);
}
//URIError: URI malformed
//    at decodeURI (&amp;lt;anonymous&amp;gt;)
//    at &amp;lt;anonymous&amp;gt;:2:11
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Selective Catching
&lt;/h3&gt;

&lt;p&gt;Let's see an example, where we handle the error using try-catch block. What if we want to handle only the TypeError and not the syntax error. &lt;br&gt;
We can do that easily, as we know all the errors are instances of their class. we can check their class and find out which type of error our try block has.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function sumOfNumbersInArray (arrayOfNumbers) {
    try{
       return arrayOfNumbers.reduce((sum, num)=&amp;gt;sum+num, 0);
    } catch(error){
        if (error instanceof TypeError)
        console.error("Invalid type. This function works with arrays only!");
        else
        throw error
    }
}
sumOfNumbersInArray(3);
// Invalid type. This function works with arrays only!

function sumOfNumbersInArray (arrayOfNumbers) {
    try{
       return arrayOfNumbersss.reduce((sum, num)=&amp;gt;sum+num, 0);
    } catch(error){
        if (error instanceof TypeError)
        console.error("Invalid type. This function works with arrays only!");
        else
        throw error
    }
}
//In the above code I miss-typed the arrayOfNumbers variable, it throws an error(else block), as that error is ReferenceError and is not an instance of TypeError
//Uncaught ReferenceError: arrayOfNumbersss is not defined
//    at sumOfNumbersInArray (&amp;lt;anonymous&amp;gt;:3:8)
//    at &amp;lt;anonymous&amp;gt;:1:1

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Stack Trace
&lt;/h3&gt;

&lt;p&gt;Let's talk about stack trace now.&lt;/p&gt;

&lt;p&gt;consider below example. It has 3 functions, function A calls B, and function B calls C.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function A () {
    try{    
        console.log("I am A, I will handle the error, and invoking B");
        B();
    } catch(error){
        console.error(error);
    }
}
function B () {
    console.log("I am B, and invoking C");
    C();
}
function C (){
    console.log("I am C and I have an error");
    throw new Error("fatal error");
}
A();
// I am A, I will handle the error, and invoking B
// I am B, and invoking C
// I am C and I have an error
// Error: fatal error
//    at C (&amp;lt;anonymous&amp;gt;:15:11)
//    at B (&amp;lt;anonymous&amp;gt;:11:5)
//    at A (&amp;lt;anonymous&amp;gt;:4:9)
//    at &amp;lt;anonymous&amp;gt;:17:1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In function A we are handling the error, but in C error is thrown, as soon as the error is thrown in C, it stops executing further and control comes to the point where it was invoked, that means in function B. Function B also stops executing and control comes to the point where it was invoked, that means in function A. Now function A sees the catch block and the error gets caught there and now program runs further without any interruption.&lt;/p&gt;

&lt;p&gt;Now that error tells information about type of error, message of the error and stack trace. &lt;/p&gt;

&lt;p&gt;Stack trace information is stored in the stack property and can be helpful when trying to debug a problem. it tells us the function name where the error occurred and which functions made the failing call. States what all things are there in the stack at the time when the error occurred. &lt;/p&gt;

&lt;p&gt;So this was all about errors in javascript. Let me know in the comments if you found this blog helpful !!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I thank my mentor &lt;a href="https://tanaypratap.com/"&gt;Tanay Pratap&lt;/a&gt; who was the motivation behind this blog.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;References: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error"&gt;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/toString"&gt;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/toString&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Introduction to JavaScript Selectors</title>
      <dc:creator>Ankita Bagale</dc:creator>
      <pubDate>Thu, 14 Jan 2021 18:24:45 +0000</pubDate>
      <link>https://dev.to/ankitabagale/introduction-to-javascript-selectors-5g77</link>
      <guid>https://dev.to/ankitabagale/introduction-to-javascript-selectors-5g77</guid>
      <description>&lt;p&gt;We have many DOM methods to save html elements in JS variables.&lt;br&gt;
In this blog, I will be explaining how method "querySelector" works. And how we can select elements more specifically using this method.&lt;/p&gt;
&lt;h3&gt;
  
  
  How querySelector() works?
&lt;/h3&gt;

&lt;p&gt;Consider a simple html code as below-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!-- html --&amp;gt;
&amp;lt;html&amp;gt;
    &amp;lt;body&amp;gt;
        &amp;lt;input type="number"&amp;gt;
        &amp;lt;input type="number"&amp;gt;
        &amp;lt;input type="number"&amp;gt;
    &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we need to store input element in JS variable, we use querySelector.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//JS code
var inputJS = document.querySelector("input");

console.log(inputJS)
//Output: &amp;lt;input type="number"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The above code in simple language means- querySelector() goes through the html document from top to bottom and selects 1st element with input tag, and returns it  which gets saved in variable inputJS.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Selector?
&lt;/h3&gt;

&lt;p&gt;What if we need to select 2nd input element instead of first, in such cases &lt;strong&gt;selectors&lt;/strong&gt; are useful to call out specifically which element to select.&lt;/p&gt;

&lt;p&gt;Whatever we write inside querySelector brackets is called as &lt;strong&gt;CSS string&lt;/strong&gt;. It should have valid CSS syntax, if written incorrectly, it gives syntax error.&lt;/p&gt;

&lt;p&gt;querySelector() method, &lt;strong&gt;searches for the element whose CSS selector matches with the CSS string&lt;/strong&gt; specified in brackets. If &lt;strong&gt;no match&lt;/strong&gt; is found it returns &lt;strong&gt;null&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;We have some basic syntaxes-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;querySelector("TagName")&lt;/li&gt;
&lt;li&gt;querySelector(".ClassName")&lt;/li&gt;
&lt;li&gt;querySelector("#idName")&lt;/li&gt;
&lt;li&gt;querySelector("[Attribute]")&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Lets check out one example:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!-- html --&amp;gt;
&amp;lt;html&amp;gt;
    &amp;lt;body&amp;gt;
        &amp;lt;input class="inputNumber"&amp;gt;
        &amp;lt;input id="idName" &amp;gt;
        &amp;lt;input type="number"&amp;gt;
    &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// JS code
var element1= document.querySelector("input");
var element2= document.querySelector(".inputNumber");
var element3= document.querySelector("#idName");
var element4= document.querySelector('[type="Number"]');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;First querySelector searches for element with &lt;strong&gt;input tag&lt;/strong&gt; in html document and returns &lt;code&gt;&amp;lt;input class="inputNumber"&amp;gt;&lt;/code&gt;, and it gets stored in variable element1.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Second querySelector searches for element with &lt;strong&gt;class inputNumber&lt;/strong&gt; ('.' represents class) in html document and returns &lt;code&gt;&amp;lt;input class="inputNumber"&amp;gt;&lt;/code&gt;, and it gets stored in variable element2.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Third querySelector searches for element with &lt;strong&gt;id idName&lt;/strong&gt; ('#' represents id) in html document and returns &lt;code&gt;&amp;lt;input id="idName"&amp;gt;&lt;/code&gt;, and it gets stored in variable element3.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Fourth querySelector searches for element with &lt;strong&gt;attribute type and its value as Number&lt;/strong&gt; ('[ ]' represents attribute) in html document and returns &lt;code&gt;&amp;lt;input type="number"&amp;gt;&lt;/code&gt;, and it gets stored in variable element4.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Multiple Selectors:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var element = document.querySelector(".inputNumber , #idName");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can specify selectors comma separated. querySelector() searches for element who has either class inputNumber or id idName.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Negate Selectors:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var element = document.querySelector("input:not(.inputNumber)");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can specify selectors inside brackets of &lt;strong&gt;:not()&lt;/strong&gt; which we don't want to be selected. querySelector() searches for element who has &lt;strong&gt;input tag but that input element should not have class of inputNumber&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;querySelectorAll():&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var elementsArray = document.querySelectorAll("input");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;querySelectorAll() searches for all the elements matching the CSS string and returns all those elements in an array. &lt;/p&gt;

&lt;p&gt;Here it will return array of all the elements with tag input. We can store that array in variable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This was just a basic understanding of selectors in JavaScript. Using this, you can build complex CSS strings. Here's a small quiz for you to check your understanding. Please write your answers in comments section.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!-- html --&amp;gt;
&amp;lt;h1 class="mainHeader"&amp;gt;Heading&amp;lt;/h1&amp;gt;

&amp;lt;div class="main"&amp;gt;
    &amp;lt;h1&amp;gt;Heading Main&amp;lt;/h1&amp;gt;
    &amp;lt;p class="para"&amp;gt;Paragraph&amp;lt;/p&amp;gt;
    &amp;lt;input type="text"&amp;gt;
    &amp;lt;p class="content"&amp;gt;Content&amp;lt;/p&amp;gt;
&amp;lt;/div&amp;gt;

&amp;lt;div class="section"&amp;gt;
    &amp;lt;input type="text"&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Write CSS string if we want to select all elements with p tag having class "para" or "content"&lt;/li&gt;
&lt;li&gt;Write CSS string if we want to select an element with h1 tag and that element should not have "mainHeader" class&lt;/li&gt;
&lt;li&gt;Write CSS string for element with p tag having class "para" and parent class "main"&lt;/li&gt;
&lt;li&gt;Write CSS string if we want to select an element with input tag having attribute type="text" which does not have parent class "main"&lt;/li&gt;
&lt;li&gt;Find the output:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var array = document.querySelector("p")
console.log(array[0]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Let's Learn Functions in Javascript</title>
      <dc:creator>Ankita Bagale</dc:creator>
      <pubDate>Thu, 14 Jan 2021 12:23:36 +0000</pubDate>
      <link>https://dev.to/ankitabagale/let-s-learn-functions-in-javascript-1kia</link>
      <guid>https://dev.to/ankitabagale/let-s-learn-functions-in-javascript-1kia</guid>
      <description>&lt;p&gt;Suppose there is a task which needs to be done again and again in your program. You will have to write the code again and again. It's a lot of repetitive work. Can this effort be saved? Yes. Functions come to your rescue!&lt;/p&gt;

&lt;p&gt;Let us begin!&lt;/p&gt;

&lt;h3&gt;
  
  
  What is a function?
&lt;/h3&gt;

&lt;p&gt;Basically it is a piece of code which needs to be written once but can be used any number of times. Let's see how to define and use them in our programs.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Syntax for Function Declaration-&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;It is same as we declare variables and assign value to it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var age = 50;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In function declaration we are assigning a program statements as a value to it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function functionName(parameter1, parameter2, andSoOn){
// program statements
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A function can have multiple or no parameters. &lt;strong&gt;Parameters&lt;/strong&gt; are the variables that are used in the program statements inside the function declaration.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Syntax for using the declared function(calling Function):&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Defining a function does not execute it. Defining it simply names the function and specifies what to do when the function is called.&lt;/p&gt;

&lt;p&gt;Earlier we declared a variable age and now we can use it in our program.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;age=age+1;
console.log("my age next year will be "+age)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the same way, we have to call function to use it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;functionName(argument1, argument2, andSoOn);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Arguments&lt;/strong&gt; are the the actual values passed to the function parameters. Here argument1 is an actual value which is assigned to the parameter1 to use in the program statements inside function.&lt;br&gt;
It will look like below on calling the function.&lt;/p&gt;

&lt;p&gt;functionName(parameter1=argument1,.....){&lt;br&gt;
//program statements&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Consider below example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//function declaration
function ageNextYear(age){
console.log(age+1);
}
//function call
ageNextYear(50);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above statements will get executed as below-&lt;/p&gt;

&lt;p&gt;ageNextYear(50) searches the function ageNextYear definition in our program, then saves 50 in parameter 'age' and then uses that 50 in place of age in program.&lt;br&gt;
like-&lt;/p&gt;

&lt;p&gt;ageNextYear(50){&lt;br&gt;
console.log(50+1);&lt;br&gt;
} &lt;/p&gt;

&lt;p&gt;Hence gives the output as printing 51 on console.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;Understanding return( ):&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Some functions produces output and some functions don't. For example above function is just printing age next year in the console. But sometimes functions while execution of the program statements evaluate some values and returns it. &lt;/p&gt;

&lt;p&gt;In short function takes the input, process it in program statements and returns the output. So this output is returned in a special statement called as return statement.&lt;/p&gt;

&lt;p&gt;When control comes across return statement, it immediately jumps out of the function program and gives the output(value written next to return) to the code that called the function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//function declaration
function square(x){
return x*x ;
}
//function call
var squareOfNumber = square(4);
console.log(squareOfNumber);
//→16
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the function reached return (4x4=16), it puts 16 value in place of function call (square(4)) and that value gets assigned to variable squareOfNumber.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;More about Parameters and Arguments&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What if we do not pass any value to parameters in function call, can we give a default value to execute the function's program?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The answer is yes, we can. We can assign default values to parameters in function declaration.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//function declaration
function square(x=3){
console.log(x*x);
}
//function call
square();
//→9
square(5);
//→25
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When square is called with no value passed, square function's parameter is defined with value 3 and that gets used in program statements execution.&lt;/p&gt;

&lt;p&gt;function square(3){&lt;br&gt;
console.log(3*3);&lt;br&gt;
} &lt;/p&gt;

&lt;p&gt;And if we pass any value like 5, then x gets re-assigned with new value 5.&lt;/p&gt;

&lt;p&gt;function square(5){&lt;br&gt;
console.log(5*5);&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What if we pass more values in function call, which one of them will be taken by parameter? And answer is extra arguments gets ignored.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//function declaration
function multiply(x,y){
console.log(x*y);
}
//function call
multiply(5,6);
//→30
multiply(5,6,7);
//→30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x saves 5, y saves 6 and extra values passed(7) will be ignored.&lt;/p&gt;

&lt;p&gt;function multiply(5,6){&lt;br&gt;
console.log(5*6);&lt;br&gt;
}&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;Arrow Functions&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What if we want our function to look compact and not bulky.&lt;/strong&gt;&lt;br&gt;
In such cases we use arrow functions. &lt;strong&gt;Arrow function&lt;/strong&gt; is just a syntax/notation to declare a function. Instead of the function keyword, it uses an arrow (=&amp;gt;) made up of an equal sign and a greater-than character.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var functionName = (parameter1, parameter2, andSoOn) =&amp;gt; {
//program statements
//return statement
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now how do we use this function. It is same as earlier:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;functionName(argument1, argument2, andSoOn)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's see an example-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var square = (x)=&amp;gt;{
return x*x;
}
console.log(square(2))
//→4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;If we have only one statement in our program inside function we can exclude the { } braces.&lt;/strong&gt;&lt;br&gt;
In such case, statement written after the arrow will be considered as return statement.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var square = (x) =&amp;gt; x*x;
console.log(square(2))
//→4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;We can exclude ( ) bracket if we have only one parameter.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var square = x =&amp;gt; x*x;
console.log(square(2))
//→4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;If we do not have any parameter, we have to write empty () brackets as part of syntax.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var printWelcome = () =&amp;gt; console.log("Welcome");
printWelcome();
//→Welcome
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Functions&lt;/strong&gt; are one of the fundamental building blocks in JavaScript. I hope this article helped you in understanding &lt;strong&gt;Functions&lt;/strong&gt; better and to use them in your programs.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
    </item>
    <item>
      <title>What is API....</title>
      <dc:creator>Ankita Bagale</dc:creator>
      <pubDate>Fri, 04 Dec 2020 16:43:49 +0000</pubDate>
      <link>https://dev.to/ankitabagale/what-is-api-1m99</link>
      <guid>https://dev.to/ankitabagale/what-is-api-1m99</guid>
      <description>&lt;p&gt;Ever wondered how travel booking sites are able to list thousands of flights and hotels for a destination and showcase the cheapest option...&lt;br&gt;
The answer is &lt;strong&gt;API&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In technical terms, &lt;strong&gt;API&lt;/strong&gt; is &lt;strong&gt;Application Programming Interface.&lt;/strong&gt; The name itself says it's an interface between two programs.&lt;br&gt;
APIs let your application communicate with other applications without having to know how they’re implemented.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why API?
&lt;/h3&gt;

&lt;p&gt;Consider you are developing translation app which takes user input in English and shows translated text in Korean language. Now to implement this if you go on developing the whole program which will translate user words in Korean, you will end up making your code more complex and will spend a lot of time.&lt;br&gt;
Instead, if you use API for translation, you just need to program to take user input and display translated output. You don't need to know how the translation is taking place. Another application will have program to translate it and API will get that translated text for you. &lt;br&gt;
This can simplify app development, saving time and money. Let's see how API works.&lt;/p&gt;

&lt;h3&gt;
  
  
  How does API work?
&lt;/h3&gt;

&lt;p&gt;Consider you are at a restaurant and you requested Noodles to waiter. Waiter will go to the kitchen(where your Noodles are being prepared) and get your order from kitchen back to you. You may not even know how to prepare the noodles.&lt;/p&gt;

&lt;p&gt;In this above example, &lt;strong&gt;waiter&lt;/strong&gt; is &lt;strong&gt;API&lt;/strong&gt;. &lt;strong&gt;You&lt;/strong&gt; are your &lt;strong&gt;translation app&lt;/strong&gt;. &lt;strong&gt;Noodles&lt;/strong&gt; are &lt;strong&gt;translated text&lt;/strong&gt; for user's English input. &lt;strong&gt;Kitchen&lt;/strong&gt; is &lt;strong&gt;another application&lt;/strong&gt;(which have program to translate to Korean language).&lt;/p&gt;

&lt;p&gt;API allows software applications to talk to each other. but how do API transfer information then?&lt;br&gt;
There are four types of actions an API can take:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. GET: Requests data from server&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;GET&lt;/code&gt; requests are the most common and widely used methods in APIs and websites. The &lt;code&gt;GET&lt;/code&gt; method is used to retrieve data from a resource. Like in translation app, translation app requests for translated text for user input text. &lt;code&gt;GET&lt;/code&gt; method of API brings response from server of that actual translating app. This response content is transmitted in the XML/JSON files. &lt;br&gt;
See below screenshot, if &lt;code&gt;GET&lt;/code&gt; method successfully brings response(translated text), it gives success code 200. If server is down or server is not found, it gives error code 400 in response. &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fqocqjgg8w6grf31sqr4i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fqocqjgg8w6grf31sqr4i.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since a &lt;code&gt;GET&lt;/code&gt; request is only requesting data and not modifying any resource, it's considered a safe and idempotent method.&lt;br&gt;
Idempotent means making multiple identical requests must produce the same result every time until server content is not changed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. POST: Sends new information to a server&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In web services, &lt;code&gt;POST&lt;/code&gt; requests are used to send data to the API server to create new data in resource. &lt;br&gt;
Consider you are filling a sign up form, when you enter your personal information and click on sign up, it takes entered data in format of XML/JSON/query parameters as &lt;code&gt;POST&lt;/code&gt; request to the server where all the signed up users data gets stored.&lt;br&gt;
If personal information is successfully stored in server, then we get 200 status code for &lt;code&gt;POST&lt;/code&gt; request in response.&lt;br&gt;
&lt;code&gt;POST&lt;/code&gt; request is not idempotent. Every time we send data to store using &lt;code&gt;POST&lt;/code&gt; request, it creates new data in resource.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. PUT: Makes changes to existing data on server&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;PUT&lt;/code&gt; request is same as &lt;code&gt;POST&lt;/code&gt; request. Difference is &lt;code&gt;PUT&lt;/code&gt; request is idempotent. Every time we send data using &lt;code&gt;PUT&lt;/code&gt; request to the API server to create data in resource, it checks if the data in resource is already present, if present then it updates the existing data in resource. If not present, it creates data in resource.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. DELETE: Removes existing info from server&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;DELETE&lt;/code&gt; operations are idempotent. If you &lt;code&gt;DELETE&lt;/code&gt; data, it’s removed from the resource. Requesting &lt;code&gt;DELETE&lt;/code&gt; data second time will return a 404 error code in response.&lt;/p&gt;




&lt;p&gt;It is important that we know what basically happens when we include anything new in our programs. I hope beginners will find this article helpful when working with APIs.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
      <category>codenewbie</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Use Git - Simplified For Beginners</title>
      <dc:creator>Ankita Bagale</dc:creator>
      <pubDate>Sun, 29 Nov 2020 10:39:58 +0000</pubDate>
      <link>https://dev.to/ankitabagale/use-git-simplified-for-beginners-4h14</link>
      <guid>https://dev.to/ankitabagale/use-git-simplified-for-beginners-4h14</guid>
      <description>&lt;p&gt;When we start to code for any project it is important to keep track of all our project versions and changes in source code files. Hence, knowing how to use &lt;strong&gt;git&lt;/strong&gt; is important.&lt;br&gt;
&lt;strong&gt;This is a beginner friendly article to help you with basic workflow of git.&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  How Git works?
&lt;/h3&gt;

&lt;p&gt;Suppose we have a project. Its first version has file1 and file2. Git stores these two files as snapshots. &lt;br&gt;
Now as part of Second Version of the project, we modified file2. &lt;br&gt;
Now git will not store the file1 again. Instead, it will just refer to file1 snapshot from version1 as "version2 file1" is identical to "version1 file1". &lt;br&gt;
And as file2 is modified, it will store file2's snapshot.&lt;br&gt;
This way git keeps track of versions of the project.&lt;/p&gt;
&lt;h3&gt;
  
  
  Git has main 3 states in which file goes through:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Modified:&lt;/strong&gt; A file is modified when we modify it but did not store it to local database.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Staged:&lt;/strong&gt; A file is staged when we marked a modified file in its current version which is ready to store into local database.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Committed:&lt;/strong&gt; A file is committed file when we safely store it in local database.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  These states lead to 3 main sections:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Working tree:&lt;/strong&gt; This is your workspace, where you copy files(of current version) from remote repository and use or modify those files to make changes for next version.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Staging area:&lt;/strong&gt; It is a file in your git directory, that stores modified files which we want to store into local database.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Git directory:&lt;/strong&gt; It is kind of a folder which stores the information and files of your project.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Basic workflow in git:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;We &lt;strong&gt;modify files&lt;/strong&gt; in working tree.&lt;/li&gt;
&lt;li&gt;Selectively &lt;strong&gt;stage&lt;/strong&gt; just those &lt;strong&gt;changes&lt;/strong&gt; which we want to be part of our next version.&lt;/li&gt;
&lt;li&gt;We do a &lt;strong&gt;commit&lt;/strong&gt;, which takes files from staging area and &lt;strong&gt;stores as snapshots&lt;/strong&gt; permanently in Git repository.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  In short:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;If particular version of a file is in git directory, it is considered as &lt;strong&gt;committed&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;If it has been modified and added in staging area, it is called as &lt;strong&gt;staged&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;if it is changed since its last checkout and has not been staged, it is &lt;strong&gt;modified&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;Go through below steps to use git in command line:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;If you have your project repository in github and you want to update your code in your system and push the code changes again to your github account, that's when git commands can be used.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Install Git:&lt;/strong&gt;&lt;br&gt;
You need to install git in your machine before using it. Open the terminal window and type below command for ubuntu/debian:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo apt install git-all
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;for other OS please &lt;a href="https://git-scm.com/downloads"&gt;click here&lt;/a&gt; to check out the commands.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Login in Git:&lt;/strong&gt;&lt;br&gt;
The first thing you should do when you install Git is to set your user name and email address.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git config --global user.name “DummyUsername”
$ git config --global user.email “demoEmail@mail.com”
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can always check if your information is saved. Use &lt;code&gt;gedit&lt;/code&gt; command. This will open a text file having username and email id.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ gedit .gitconfig
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Create Git Directory:&lt;/strong&gt;&lt;br&gt;
You will need a workspace(New folder) to copy your github repository in your machine. So we are going to use &lt;code&gt;mkdir&lt;/code&gt; command to create workspace. We will make newly created workspace as current directory to proceed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ mkdir DummyName
$ cd DummyName/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you already have a project directory and you want to start controlling it with Git, you first need to go to that project’s directory and initialise it with git.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cd ProjectDirectory_path
$ git init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Clone Remote repository:&lt;/strong&gt;&lt;br&gt;
To work on your project present in github account, you will need to get a copy of your project's git repository in your system. For this, use &lt;code&gt;Clone&lt;/code&gt; command to copy repository in your workspace.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git clone “Enter here url of your remote repository”
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can check that new folder with project's repository name is created inside the workspace folder by using &lt;code&gt;ls&lt;/code&gt; command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make our newly created repository folder as current directory to proceed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cd DumyRepoName
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You are ready to code now. You can open the folder(newly created repository in workspace) in code editor. You can create/update your files and write/update your code.&lt;br&gt;
This code will be saved in your desktop only. When we are done with the coding, we will want to update code in our github account.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Final Step: add, commit, push&lt;/strong&gt;&lt;br&gt;
Using a &lt;code&gt;add file_name&lt;/code&gt; command you can add your code changes to staging area. This command states that you want to include file_name's changes included in your next commit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git add .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;.&lt;/code&gt; is used to include all files&lt;/p&gt;

&lt;p&gt;You can use &lt;code&gt;status&lt;/code&gt; command to check the files state.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use &lt;code&gt;commit&lt;/code&gt; command to commit the code with comments. This will take files from staging area and store the files snapshots in git repository using &lt;code&gt;git push&lt;/code&gt; command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git commit -m “your comment goes here”
$ git push
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Yay! We have our files updated in git repository. It was that easy if we understand the concepts and git commands.&lt;br&gt;
I will recommend you to go to official documentation and always use &lt;code&gt;git help&lt;/code&gt; command for more information:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://git-scm.com/doc"&gt;https://git-scm.com/doc&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="https://guides.github.com/activities/hello-world/"&gt;https://guides.github.com/activities/hello-world/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

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