Image for post
Image for post

In the web applications, sometimes a user will be disconnected from the network. At this time how the application will perform. So, if you create a good app, so it is must detect when the user goes offline and behave accordingly. In some of my freelance project, I was facing this type of problem. After that, I referred HTML5 MDN for working with offline and online events.

For creating a good application, you must know when the user goes offline and write logic accordingly. There is some use-case when detecting offline and online events are important.

Use-case 1 :

When a user is filling a long form and middle of filling the form, the user goes offline due to a power cut or some problem of connectivity. In this use-case detect an offline event and save data in local storage and when user will again be connected with the network, data will send to the server. …


Image for post
Image for post

Every HTML element having display property. Display property tells to web page how an element will render on the web page. By default, all elements of HTML having inline display property. By using of User Agent stylesheets, some elements like div, section, ul having block display property.

User agent style sheets are overridden by anything that you set in your own style sheet. …


process is the core module of Node JS and we don’t have a need to install this module. You can simply access this module by require method.

const process = require('process')

If you don’t want to require process module, you directly use it.

process.env

By the use of an above snippet of code, you access all the environment variables and values of the system in Node JS app. Like process.env, you will access all the methods of process from any of the files in Node JS app without requiring it. process.nextTick …


Image for post
Image for post

Exponent power of a number:

We get the power value of exponent over the base number by using three methods:

  1. By using of default method: Math.pow ().
  2. By Looping: for loop and while loop.
  3. Recursive method.

Math.pow( ):


Reverse a string :

In JavaScript, you can reverse a string by three ways:

  1. Using default methods ( split (), reverse (), join ())
  2. Using decremented loop.
  3. Using of recursion function.

Using default methods:

Reverse a string by using three default or built-in functions:

  1. split () // split a string into array of character.
  2. reverse() // reverse the array.
  3. join() // join the element of the array.
Image for post
Image for post

Chaining all three default methods:


Image for post
Image for post

Today we are discussing class constructor and ngOnInit. This is very frequently asked question in the interview if you are going for an Angular Developer.

Angular developer sometimes writes some code in the constructor which are related to angular and sometimes they getting undefined because constructor calls before creating the component.

Now here, we are discussing constructor and ngOnInit.

If you want to see original article, please go to The Dev Family

Constructor will call first after that ngOnInit will fire.

What is constructor :

A constructor is not the concept of Angular. It is the concept of JavaScript’s class. …


Image for post
Image for post

In modern time, JavaScript stack is booming in the software development field. All companies like JS technologies like Node JS, Angular, React, Vue, Express, etc. So, in today’s life of a software developer is incomplete without the JavaScript. Today we will discuss OOJS (Object Oriented JavaScript) main concept: Objects.

Introduction :

Object-oriented languages are identified through their use of classes to create multiple objects that have the same properties and methods. JavaScript is slightly different from other class-based programming languages because, in ES5, there was no concept of the class keyword in the JavaScript. ES5 is all about functional programming. …


Image for post
Image for post
Aggregation by pipeline

Today we are discussed about Aggregation in MongoDB. Aggregation is the process of grouping the multiple documents and perform any operation and getting the single result. In this medium story, we will take a look at how to create the basic transformation of documents using aggregations.

There are 3 ways to perform aggregation on MongoDB documents:

  1. Aggregation Pipeline
  2. Map-Reduce Function
  3. Single Purpose Aggregation Methods

Basic Syntax :

db.collection_name.aggregate(AGGREGATION_OPERATIONS)

AGGREGATION PIPELINE :

MongoDB aggregation framework using the data-processing pipeline. MongoDB documents are processed by aggregation pipeline and give the aggregate result. The pipeline method using the MongoDB native methods like a $match, $group, $sort etc.

db.collection_name.aggregate([...AGGREGATION_OPERATIONS...])

For working with aggregation, we need to insert some data in the database. …


Now in this medium story, we can create a simple APIs in Express JS ( Node JS Framework ). In this story, we can create a CRUD (Create, Read, Update, Delete) APIs. If you are new in the Node JS and want to learn how to create the basic server and create a basic APIs in Node JS, please read my medium story: Create HTTP Server in Node JS

Create a project in Express :

If you are new to Express framework and doesn’t know how to create a project in Express.js, please refer my medium story: Setup Basic Server with Express Framework.


In the previous article, we have already discussed the searching techniques in the JavaScript. If you want to learn the searching techniques in JavaScript, please read my medium story: Searching techniques in JavaScript. Now in this story, we discussed the sorting techniques in the JavaScript. There are several sorting techniques in JavaScript like insertion sorting, selection sorting, bubble sorting etc.

Selection Sort :

The selection sort is the type of sorting algorithm in the programming. It is the simplest type of sorting algorithm that’s why it is used for sort the small list.

About

Vaibhav Sharma

Software Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store