Common concepts of programming

So learning different languages is not a big taboo… concepts are same everywhere you just need to start with any one of them. In this article, I will talk about common concepts of programming that will same in every programming languages.

This article will divide into 4 parts 
1. Variables
2. Functions
3. Loops
4. If-Else statements

So these 4 things you will find in every language and as I am Javascript developer so I will try to make you understand things in JS only so without wasting much time lets begin!

1. Variables

Variables are just containers to holding the values or data.

In JAVASCRIPT we define variables by commonly three ways let, const, var
ES6 (the new specification of JS) we are using let, const most of the times. So how we define the variables?? Ahh no-worries

let a = 20;
const b = 30;
var c = 40;

So here a, b, c, are just containers who are holding the values. If I talk about identifiers so we use “ let” to define those variables whose values might change in future or have block scope in that scenario and “const” is used for those variables whose values will not change in anyhow. Const has some caveats when using arrays and objects

Now “var” is used to make global variable. This was a glimpse of variables and how we define and use. now let's move to the next part that is Functions.

2. Functions

So the function is very very important in every programming language because while you start making an app it starts with a single module with different functions or a single function, so the knowledge of function is very important and its functioning is same everywhere just syntax differ (like every function returns the values in every language)

Let's take an example in javascript function is defined by function keyword.

Example : 
function sum(a, b) { return a + b }
sum(1, 3)

In javascript there is a different way to define functions like:

  • Self-invoking function : 
    A self-invoking anonymous runs automatically/immediately when you create it and has no name, hence called anonymous. Here is the format of self-executing anonymous function:
(function (a, b){
return a+b;
  • Function expression
var getRectArea = function(width, height) {
return width * height;
// expected output: 12
  • Arrow function : 
    It is a new way for writing functions which is named as arrow function
  • Anonymous Function or callbacks : 
    The function which does not have any name that is called an anonymous function or callbacks.

3. Looping

There are 2 types of loops which are similar in every language.

  • For loop: an example of for loop is
for(let i = 0; i<5; i++)
  • While loop: an example of a while loop is:
while(condition>0){ do something here}

4. If-else Statements

if-else statements are divided into two parts one is simple if-else and another is nested if-else.
if-else uses on condition based statements.

I hope this article is useful for beginners I will try to improve it. Thanks for reading keep coding $ :-) $