<?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: Sachin Pant</title>
    <description>The latest articles on DEV Community by Sachin Pant (@pantsachin).</description>
    <link>https://dev.to/pantsachin</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%2F521497%2F333798bc-84a0-4828-b184-3cb952d36d02.jpeg</url>
      <title>DEV Community: Sachin Pant</title>
      <link>https://dev.to/pantsachin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pantsachin"/>
    <language>en</language>
    <item>
      <title>Functions - What are they?</title>
      <dc:creator>Sachin Pant</dc:creator>
      <pubDate>Sat, 05 Dec 2020 21:23:02 +0000</pubDate>
      <link>https://dev.to/pantsachin/functions-what-are-they-4g47</link>
      <guid>https://dev.to/pantsachin/functions-what-are-they-4g47</guid>
      <description>&lt;h1&gt;
  
  
  What are Functions?
&lt;/h1&gt;

&lt;p&gt;Functions are those building blocks of a programme which help you do repetitive work. They help save time. They reduce the amount of code. They help save our energy and they might increase the efficiency of our programme. &lt;/p&gt;

&lt;h1&gt;
  
  
  How do we declare a function?
&lt;/h1&gt;

&lt;p&gt;There are different ways to declare a function. For e.g. -&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Regular Binding -  &lt;code&gt;const square = function(x) {&lt;br&gt;
 return x*x;&lt;br&gt;
};&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Declaration Notation - &lt;code&gt;function square(x) {return x*x; };&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Arrow Function - &lt;code&gt;const square = (x) =&amp;gt; {return x*x; };&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We use one of the above ways according to our comfort and type of a programme.&lt;/p&gt;

&lt;h1&gt;
  
  
  What is Call Stack?
&lt;/h1&gt;

&lt;p&gt;Suppose you declared a function and then have to call back later in a programme. After getting a value from it we want to execute our code after the point where we called the function. For that we need to store the point where we called the code in a memory, this is our call stack. It's duty is to remember where in our programme we call a function. It should never fill whole of our memory otherwise it will stop the programme and ask to clear the memory or as it is called in the programme 'blow the stack'.&lt;/p&gt;

&lt;h1&gt;
  
  
  What is Recursion?
&lt;/h1&gt;

&lt;p&gt;A function that calls itself is called a recursive function. It is okay for a function to call itself as long as it is not overflowing the stack. It allows us to write a function in a different style.&lt;/p&gt;

&lt;p&gt;It could be easy for a reader to understand the code written in a recursive format. But it might not always be the case when we talk about code efficiency. As many a times a function written in a loop might be more efficient than a function written in a recursive format. &lt;/p&gt;

&lt;p&gt;So it totally depends on the need of the programme whether to write a function in a normal format or a recursive format.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;This was the basics of function and we can see that functions are there to make the life of a programmer easy and to help reduce the time and workload of a programme and a programmer.&lt;br&gt;
It is the building blocks of a programmer. Just like cells are a building blocks of lives to a tissue.&lt;/p&gt;

&lt;p&gt;This is a blogging challenge from &lt;a href="https://ejs-challenge.netlify.app"&gt;#teamtanayejschallenge&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can visit the website at: &lt;a href="https://ejs-challenge.netlify.app"&gt;https://ejs-challenge.netlify.app&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Programme Structure </title>
      <dc:creator>Sachin Pant</dc:creator>
      <pubDate>Fri, 04 Dec 2020 18:35:31 +0000</pubDate>
      <link>https://dev.to/pantsachin/programme-structure-2g3a</link>
      <guid>https://dev.to/pantsachin/programme-structure-2g3a</guid>
      <description>&lt;h1&gt;
  
  
  What is Programme Structure
&lt;/h1&gt;

&lt;p&gt;Just like any spoken language where we have distinct parts in a sentence which have a meaning of their own and when they combine they form a bigger sentence, and when we combine these sentences we can have different styles of writing such as a paragraph, poem, article etc similarly in programming we have different fragments which are called expressions which have their own value. When we stitch together these fragments we get what we call a programme. &lt;/p&gt;

&lt;h1&gt;
  
  
  Bindings - (Variable Storage)
&lt;/h1&gt;

&lt;p&gt;Bindings could be compared to an Octopus' tentacles as they are there to grasp different things as per the requirement, likewise in programming a value is grasped as per the requirement by a variable.  This helps to maintain the internal state of the programme.&lt;/p&gt;

&lt;h1&gt;
  
  
  Binding Names
&lt;/h1&gt;

&lt;p&gt;Binding names or variable names have certain rules that everyone has to follow. It can't start with a numerical. It cannot have a special character except '$' or '_ '. We can't keep keywords as variable names, for e.g. 'Let', 'Var' etc.&lt;/p&gt;

&lt;h1&gt;
  
  
  Functions
&lt;/h1&gt;

&lt;p&gt;Our main aim of programming is to reduce work and functions help us do that. It is a value which keeps changing on giving different arguments. We execute a function by writing its name followed by parenthesis. This process is known as calling a function. There are a lot of pre defined functions in any language, for e.g. in Javascript one of those is 'Console.log()'. It is used to output a value to the console of a browser.&lt;/p&gt;

&lt;h1&gt;
  
  
  Control Flow
&lt;/h1&gt;

&lt;p&gt;When we execute a programme it is executed from top to bottom. The control flow depends on the type of executions we have given in the programme. All programmes don't execute linearly. Some of them divide like a highway or branch out like a tree. This type of execution takes place in conditional execution.&lt;/p&gt;

&lt;p&gt;Conditional executions can be created with the use of different keywords in Javascript. For example if, while, for etc.&lt;/p&gt;

&lt;h1&gt;
  
  
  Indenting Code
&lt;/h1&gt;

&lt;p&gt;The compiler doesn't execute the code according to lines it can execute a long straight-line code. But for practical purposes and for our understanding we use proper indentation i.e. proper spacing between new open block. Most code editors these days come with tools to help look the code beautiful. &lt;/p&gt;

&lt;h1&gt;
  
  
  Breaking out of a Loop
&lt;/h1&gt;

&lt;p&gt;It is very important that our code should not be an open ended code that means a code which will not or cannot stop itself and it will keep iterating over itself. It could make our coding environment irresponsive which could lead to loss of work. There are different methods to break out of a loop apart from defining the conditional breaking out of the loop.&lt;br&gt;
the expression 'break;' is one method to come out of the enclosing loop it is in. The other expression is 'continue', It doesn't stop and comes out of the loop, it jumps out of the body and continues with the next iteration.&lt;/p&gt;
&lt;h1&gt;
  
  
  Updating Bindings Succinctly
&lt;/h1&gt;

&lt;p&gt;There are many ways to increase the value of a variable in a loop. In conventional way we write the whole equation like this:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;counter = counter + 1;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;But to type quickly, Javascript offers shortcuts such as&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;counter += counter&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;even more shorter equivalent is&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;counter++&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;h1&gt;
  
  
  Capitalisations and Comments - Accepted Practices
&lt;/h1&gt;

&lt;p&gt;How to use capitalisation when declaring variables. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;smalllittlekitten - As we can see this could be confusing at times to understand what is written, so we avoid declaring variables like this.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;smallLittleKitten - This is an accepted format and it is easy for the reader to interpret what is written.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;SmallLittleKitten - The first letter cannot be a capital and this is not an accepted format.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;small_little_kitten - This is also allowed but it could really look too big when we name a complex and an important variable. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What if someone else has to read a code written by you. If you want explained what exactly a function is doing or haven't written a code following the best practices the reader might get confused. To tackle those situations we should try and inculcate the habit of writing comments wherever you feel the reader might get confused. As it is often said a good code is not a code that is easily executed by a machine but that one which is easily understood by a human.&lt;/p&gt;

&lt;p&gt;Conclusion: &lt;/p&gt;

&lt;p&gt;Programme Structure is the process flow of a programme from execution, to control flow to how a programme ends. So, how we write a programme to the logics we use everything matters in a programme and comes under the umbrella of programme structure.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ejs-challenge.netlify.app"&gt;#teamtanayejschallenge&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
      <category>codenewbie</category>
    </item>
  </channel>
</rss>
