Skip to main content

Posts

Map,Filter,Reduce array functions in Javascript

Today let's discuss about the following array functions in Javascript which most of the developers use it for ease of use Map function actually reads thru the entire array and we can perform any operation on each array item The output here would be Filter function as the name suggests we can add any condition and will return only values returning true The output here would be Reduce function it is used for accumulating values in a array by doing some kind of arithmetical operation to each item in array. In the following example we are using addition as an example The output here would be
Recent posts

Destructuring in Arrays & Objects

 Today we will learn about the de structuring in java script. Let us take a simple example how a regular array is defined var capital =["Delhi","London","Paris"] now if we want to access London then we have to pass the value as capital[1].  Now an alternate way and when we want to remember the names rather than indexes to query an array is var [India,England,France] = ["Delhi","London","Paris"]  In here in order to access London we can say console.log(England) and the output would be London This is a simple way to de structure an array. Similarly we can do the same the for an object as well const myfav = { fruit : "apple" , color : "red" }; console . log (myfav); If we have multiple values in an object const myfav = [ { fruit : "apple" , color : "red" }, { fruit : "mango" , color : "yellow" } ]; Now if we have to get mango details then it shou

REST API (GET,POST,PUT,PATCH,DELETE)

 The word API means application programming interface. Predominantly they are two important protocols which are used in world a) SOAP API (Simple object access protocol) API b) REST API means representational state transfer API's are used to interact with the web applications, many of the major applications create API's so that the end users can interact with their platform programmatically. Similar to database where we can perform operations such as insert, update, delete. In API's also we can perform such operations. Rest API is one of the highest used API's in the current web applications So in Rest API we have the following methods calls a) Get - Get method is used to fetch the data from a web application b) Post - Post method is used to insert the data into a web application c) Delete - As the name suggests delete method is used to delete data from a web application, in here we can perform a select deletion or complete deletion as well d) Put - Put method is used t

How to Push Node Js code into Heroku

 Simple native or client side java script can run on browser session can give us the desired output. This can be run either directly on browser if we have all the code on our machine or may be host it on github and can be accessed everywhere without needing to have code on our local machine Github can only run client side javacript code but if we have server side javascript then we may need to use service providers such as heroku/AWS/Google/Azure to run our application Server side coding is done for more complex applications and also not to expose our entire code to the rest of the world For our code to be deployed following are the steps  create. a Procfile with same naming convention and add the following line web: node index.js. This will help the heroku to identify what is the staring JS file on which the code should be run git init git add . git commit -m "version name" heroku create app name . This is to give a specific app name or else heroku would create a name for ou

How to push git code into a repository with out all node packages

 As am trying to learn node JS, I've learnt that we need a lot of packages to run a web application. Like any web app we would want to push (store) this code in Github. No one wants to have all the projects present in our local machine. Storing data in Github applications will help us to access the code from any where any system. Also we get to choose if we want this application to be public/private In a simple application we would be requiring so many packages eg As we can see they are so many packages and ideally we don't require all this code to be uploaded in Github. As long we have uploaded package.json we can always download these files by using the following command i.e. npm -i install once we download the project from github While uploading the project to github we need to create .gitignore file and enter the filenames which we want not to be uploaded ".gitignore" file is a hidden file For ignoring the node modules enter the following directory Then next steps

How to use AWS CLI for uploading/downloading/deleting files

 Hello again It's been a lot of time that we have posted here. So let's start with AWS S3 CLI.  We can use AWS CLI for various operations such as Uploading files from local machine into S3 bucket Downloading files from S3 bucket into local machine Listing all the files in a S3 bucket Deleting files from the S3 bucket For all the above operations to be performed we would need relevant access permissions to the specified bucket as well. Apart from permissions the three things which we would need are a) Bucket name b)Access key c) Secret Access key First lets install AWS CLI on our machine. In Mac Installing aws cli curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg" sudo installer -pkg AWSCLIV2.pkg -target / In order to test this has worked or not try the simple command aws --version We should get a result in above format Now lets configure for that we need to pass the following command aws configure upon clicking enter it would ask for enter ac

$LOOKUP ( Similar to LEFT OUTER JOIN in RDBMS) in MongoDB

In RDBMS, we have different type of joins to join the tables and get the required data from joined tables. As MongoDB is a NO Sql database, MongoDB will not support those type of joins. But we can implement LEFT OUTER JOIN using $lookup function in MongoDB. This function is there in MongoDB 3.2 version. To join two collections we need to have a common field in both the collections. $lookup works with aggregate function only. Syntax: db.collection1.aggregate([  {     $lookup:       {          from:"collection2",          localField:"common field name from collection1",          foreignField:"common field name from collection2",          as:"Alias name for collection2"      }  } ]) Here in above syntax, collection1 -- Collection name which is acts like parent table. collection2 -- Collection name which is acts like child table and this will be joined with collection1. "common field name from collection1" -- Join column