I am Computer Engineer by profession, passionate about technological advances in software technology, enthusiast learner. Also loves to read literature of historical & social importance.
/**
* To apply recursion
*/
function factorial(number){
if(number<=0)
return number;
var factorial=1;
for(var i=1;i<=number;i++)
factorial = factorial*number;
return factorial;
}
var number = 5;
console.log("Factorial of "+number+" is :"+factorial(number));
/**
* To demonstrate the functions
*/
//parameterized functions
function getSimpleGreetingMessage(personName){
return "Hello, I am "+personName+", Good morning";
}
//parameterized functions with Default parameters
function getGreetingMessage(personName,message="Good morning"){
return "Hello, I am "+personName+", " + message;
}
//rest parameters functions
function getArticulateGreetingMessage(...params){
var message ="Hello,";
for(var i=0;i<params.length;i++)
message = message+","+params[i];
return message;
}
//anonymous functions
var howAreYou = function(name){return name +" How are you..";}
var howAreyouDoing=function(name){return name +" How are you doing..";}
var personName = "Tejas";
var greetings=getSimpleGreetingMessage(personName);
console.log("default Greetings::"+greetings);
greetings=getGreetingMessage(personName,"Good night");
console.log("special Greetings::"+greetings);
greetings=getGreetingMessage(personName);
console.log("default Greetings::"+greetings);
greetings=getArticulateGreetingMessage("Hey","I am Tom", "good evening","wanna watch movie","say MI-6");
console.log("articulate greetings :"+greetings);
greetings=getGreetingMessage(personName,howAreYou("John"));
console.log("special greetings::"+greetings);
greetings=getGreetingMessage(personName,howAreyouDoing("Miki"));
console.log("special greetings::"+greetings);
//Assign functions to variables
var greetMessage = getGreetingMessage;
console.log("Greet to Johan ::"+greetMessage("Johan"));
//passing function variabls as arguments
function gossip(greet,ask,name1,name2){
return name1 + " says :"+greet(name1)+","+ask(name2)
}
console.log("gossip1 ::"+gossip(greetMessage,howAreYou,"Ina","Mina"));
console.log("gossip2 ::"+gossip(getGreetingMessage,howAreyouDoing,"Mina","Ina"));
/**
* To demonstrate if, if elseif ladder, switch case
*/
var numerical = 10;
if(numerical>0)
console.log("it is positive number")
if(numerical>0)
console.log("it is positive number");
else if(numerical<0)
console.log("it is negative number");
else
console.log("it is ZERO");
var fruit = "Mango";
switch(fruit){
case "Mango":{
console.log("It is green, orange or yellow in color");
break;
}
case "Watermelon":{
console.log("it is green in color");
break;
}
case "banana":{
console.log("it is green or yellow in color");
break;
}
default : {
console.log("i dont know color of this fruit : "+fruit);
break;
}
}
Operators represent essential part of any programming language. ECMAScript standard as well supports rich set of operators. Very Few of them are demonstrated below.
/**
* There are sets of arithmetic, relational, logical, bitwise and conditional operations
* This will demonstrate few operations to be done on variables
*/
var num1=20;
var num2=10;
console.log("Addition :: "+(num1+num2));
console.log("Modulus :: "+(num1%num2));
console.log("pre increment :: "+(++num1));
console.log("Grater than :" + (num1>num2));
console.log("bitwise And" + (num1&num2));
console.log("bitwise OR" + (num1|num2));
Hoisting term refers to way variables are declared in javascript. if we declare variable with VAR as keywords they will be hoisted at beginning of script during compilation. That means declaration will automatically move to start of file in global scope. LET keyword does not support concept of hoisting. Hence if we want to declare variable with local scope we must use LET.
/**
* To demonstrate the var variables support hoisting and let variables do not.
* hence if var is declared inside blocks they are still accessible outside due to hoisting effect.
* As a part of hoisting all declarations are moved to the beginning of function or file.
*/
function sayHi(){
for(var i=0;i<5;i++){
var message1 = "I am Tina";
console.log(i+" : inside for loop message1 ::"+message1);
let message2 = "I am Hina";
console.log(i+" : inside for loop message2 ::"+message2);
}
console.log(i+" : message1 :: "+message1);
//since i, message are declared by var, they support //hoisting, hence they live even outside of block where they were declared.
//console.log("message2 :: "+message2)
//since message2 is declared by let, it was not hoisted hence //it lives upto end of //the for block.
}
sayHi();
Const keyword is used to declare constant variables. Immutable is the one whose value cannot be modified. Const is the one whom we can assign value only once.
/**
* to demonstrate the const variables, const variable are immutable
*/
const PRIMARY_VALUE = 100;
//PRIMARY_VALUE=200; second time assignment not allowed
console.log("PRIMARY_VALUE:::"+PRIMARY_VALUE);
const NUM_ARRAY = [1,2,3,4,5,6,7,8,9];
NUM_ARRAY.push(10);
//NUM_ARRAY = [11,12,13,14,15];//since array is const, reinitialization is not allowed. it will throw error
console.log("NUM_ARRY::"+NUM_ARRAY);
To demonstrate Local scope and global scope of variables.
/**
* to demonstrate local scope and global scope
*/
var message = "I am Tom"
function sayHi(){
var message ="I am Tina";
{
let message = "I am mina";
console.log("Hi,"+message);
//let message=""; //duplicate declaration not allowed by alread declared let variable
}
console.log("Hi,"+message);
{
let message = "I am Hina";//same named let variable allowed to be declared in different block.
console.log("Hi, "+message);
}
}
console.log("Hi,"+message);
sayHi();
ECMAScript or ES is specification of programming language to be used commonly for client side processing on World wide web. It is standardized by ECMA International organization.
Javascript can be termed as concrete implementation of ECMAScript standard. That means Javascript syntax should confirm to standards of ECMAScript & to be supported across all kinds of system.
HelloWorld Example,
HelloWorld.js
/**
*
*/
var message = "Hello World, I am being run by NPM"
console.log("message ::"+message);
It is google provided service in category of Backend as a service(BaaS). We probably know Software as a Service SaS, which talks about giving licensed subscriptions to end users for example Netbanking profile in layman terms. But then we move towards cloud computing, which says Platform as a Service which promises servers, platforms as service to host. Now we have one step further Backend as service, Firebase is one example. It eliminates need of backend components through promising features like database, authentication, services etc. Probably provides some level of freedom from developing some general backend features like login, security etc. Firebase can be thought in combination with front end components like Android/ios apps, AngularJS etc. If this interests you, checkout below link to get introduced with Firebase as one candidate of BaaS.
End user can interact with Windows OS in two ways either by Graphical interface or through Command Line commands & scripting. For example one can do Ctrl+c, Ctrl+v to copy paste file. Or we can use Copy command in command line(cmd) to copy file. Batch scripts are always run on Command Line.
How to open command line.
press Windows Key + R to open Run and write cmd to open.
or write “Command Prompt” in windows startup menu search to open that app.
Command Prompt
On command prompt we can enter commands to do tasks we want. For example lets print current date.
Output of Date command.
What is Command – Commands are inbuilt programs provided by Operating system. They can be run on Command prompt. Also command can receive input arguments. Here “date” is command, “/t” is argument which says display current date only.
What is Script – In real life, tasks can be more complex rather than printing only current date. For example we would want to take backup all files from directory called “Customer Records” everyday at 12 midnight and copy them to another folder & turn off machine. Single OS command cannot achieve this task. Script is the answer. It is batch programming language, which can be used together with in-built commands to create .bat file. Then “.bat” files can be run on command line. Batch programs are stored in file with extension .bat.
01HelloWorld.bat
@echo off
echo "Hello World, this is first batch program"
pause