The ultimate guide to JavaScript class pattern explains how the prototype chain works. It explains how we can chain multiple prototypes together. However, for the sake of simplicity, I left out how a put operation on an object property works. Most misunderstandings in JavaScript arises from the assumption that the put operation works similarly to the get operation. Unfortunately, that is not how it works.…

Read More

Consider an empty object. Print the object using toString method.

const obj = {};
console.log(obj.toString()); // [object Object]

We get the result [object Object] in the console. How does it work? (Interview question). Developers who have a strong background in C++ or C# will blindly attribute it to OOPs. All objects inherit from Object.

JavaScript is to Java what Cartoon is to Car.

Read More

The github repo, react-webpack, has the minimal scaffolding for a React web app with Webpack 4. The tutorial explains how the project was built.

New project

Create a new project

yarn init

Install Webpack as devDependency.

yarn add webpack webpack-cli webpack-dev-server --dev

Create Webpack configuration file:

const path = require('path'); 
module.exports = {     
  entry: './src/index.js',     
  output: {         
    path: path.resolve(__dirname, 'dist'),
    filename: 'bundle.js',
Read More

This is Part 2 of my tutorial on Push notifications. Please click the link for Part 1 of the tutorial. We are building a Retweeter app. The Retweeter app is a React native app which displays a list of tweets it receives from a push notification. The user has an option to retweet some of the tweets.

In Part 2, we are going to build the server infrastructure for push notifications using AWS Lambda.…

Read More

Push notifications was originally an iOS concept. Apple has a push notification service called APNS. App that wants receive notifications should register with the APNS. A server component should send notifications to APNS directed towards one or more devices. The app receives the push notification from APNS and does one of the following actions:

  1. Display a notification or short text message
  2. Play a sound
  3. Update the badge in app icon
  4. Allow the user to perform an action

As you can see, push notifications are a powerful feature in iOS.…

Read More

What is a HOC?

Higher Order Component (HOC) is a function which accepts a base component and returns a decorated component.

const hoc = BaseComponent => props => (
  <BaseComponent {...props} />
)

The component that the HOC returns is a stateless functional component. At its most basic form, the base component is rendered with all the supplied props. The props can be overridden by a variation of HOC which accepts an option or configuration.…

Read More