Basic Terms Before Starting Programming
Let's walk through some of the terms used widely in a programming language :
Object - It's used to store different values in the form of key and value pairs.
// Syntax
var obj ={
key : value
}
// If a box has different colors of balls, their number will be represented in the form of an object as follows :
var listOfBalls ={
green : 22,
red : 10
}
Comment - It is similar to the person who exists but not for you. Similarly, a comment is something that is written but the programming language doesn't consider it. You can comment in the following ways :
// This is a comment.
/* This is one another comment. */
Variable - Do you have a name? Of course, everybody has one. What is its use? It is used to specifically call you. Right? Similarly, anything that possesses data is given a name so that whenever it's required, it can be called/used via its name. It's always written on the right-hand side.
var number = 1; //number is a variable.
var name = "CLI App" //var is used in JS
Function - If I compare it with one of the daily life objects i.e Washing Machine, i.e new clothes are sent inside it, but it performs the same operation of cleaning them. Here,
- Input is dirty clothes
- Processing is what happens inside the machine
- Output is clean clothes
In a programming language, a function is similar to the washing machine, in which new data is sent, but the same operation is performed, no matter what. Here,
- Input - Data sent
- Processing - Operation Performed
- Output - The data received after operation sumNumbers is the Function Name.
number1 and number2 are parameters. There can be n number of parameters.
62, 89 are the arguments that are passed to the function.
function sumNumbers(number1, number2)
{
var sum = number 1 + number 2;
}
var result = sumNumbers(62,89);
Array - It is to store some things together. The first element is at position '0'.
var colorArray = ["Red", "Black","Blue"];
//to access the values of the array
colorArray[0] = Red;
colorArray[1] = Black;
colorArray[2] = Blue;
For Loop - It's similar to getting up daily on every single day of your life until the last day of your life. That is you are doing the same thing in a loop. If I had to write this in the format of a code, it would have been as :
for(var i = The day you were born ; i<=day you will die;i=i+1)
{
//getting up
}
Which is equivalent to :
for(var i = 1; i<=n;i=i+1)
{
//perform a specific operation
}
Conditional Statements - It's similar to thinking of all the cases that are to be handled if we go late at home. If mom will ask xyz then I will say abc else I will say deb. In code , it will be written as :
var num = 0;
if(num==0)//condition
{
console.log("Number is 0");
}
else
{
console.log("Number is not 0");
}
var num = 5;
if(num>0)//condition
{
console.log("Number is positive");
}
else if(num<0)
{
console.log("Number is negative");
}
else
{
console.log("Number is 0");
}
NOTE - EVERYTHING IN JAVASCRIPT IS AN OBJECT, AND ALL THE KEYS BECOME PROPERTY OF THE OBJECT.




