How To Format Date In JavaScript

In this tutorial, you’ll learn how to format date in JavaScript. Working with date is a common scenario when creating web applications. JavaScript Date Time You can get the current date and time in JavaScript using the Date object. // the following gives the current date and time objectnew Date()Using the date object you can print the current date and time. let current_datetime = new Date()console.log(current_datetime.toString())The above code outputs the current date and time as shown: [Read More]

How to Get Date in Text in JavaScript

How to Convert Date to Text in JavaScript?

let currentDateObj = new Date();
let currentDate = currentDateObj.toString();

As seen above the Date object has the .toString method which converts date to string.

How to Make API Calls In Next.js

How to make an API call after the page has rendered in Next.js

In this Next.js video tutorial, you’ll learn how to make API call in the client side using useEffect hook and fetch API.

How to Mask Phone Number | JavaScript

How to mask characters in a string such as mask few numbers in Phone number using JavaScript ? Let’s write a simple JavaScript method to mask characters in a string. What we are trying to achieve, mask a phone number such as +919895590552 to +919895****** function mask(mobile_number, maskCount){ let nonMaskedNumber = mobile_number.slice(0, 0-maskCount); let maskChar = '*'.repeat(maskCount); return `${nonMaskedNumber}${maskChar}` } The above function does the job but it needs to be adjusted for certain edge cases. [Read More]

How to Sign Out of GMAIL App

How to logout of Gmail App from your Android device? or How to remove Google account from Android device ?

In the following video tutorial, I demonstrate how to remove, sign out or logout of Gmail or Google from your Android device.

How to Slice String in Reverse Using JavaScript

How to remove last few characters of String using JavaScript Slice ? Every time trim the last 6 characters from the phone number. For example, +919895590123 and make it +919895. Now you can use slice straight away if you know where to end. '+919895590754'.slice(0,7) // ## `+919895` But it doesn’t work is it’s different length phone number like +1219895590345. So the solution would be to use negative index for end parameter. [Read More]

Liquid Exception: undefined method `tainted?` for 2:Integer

While running Jekyll I was getting the following error, Liquid Exception: undefined method `tainted?’ for 2:Integer The above issue occured when after a windows re install I had to re install Ruby. The issue seemed like the newer version of Ruby was not compatible with the Jekyll version(4.1.1). I upgraded the Jekyll version to 4.3.2 and the error disappeared. That solves the issue. But below I have described how I being a non ruby guy upgraded the Jekyll version. [Read More]

Next.js Image Not Found

Image not found while setting src in Next.js

Issue was the place where I was keeping my images folder. Images folder needed to be inside the public directory. And here is how it was referenced in the component,

<Avatar alt="Remy Sharp" src="/images/profile.jpg" />

Next.js version : 13.3 Next.js version : 13.3

Operator "+" cannot be applied to types "Number" and "Number"

While assigning variable type as Number got the following error in TypeScript, Operator ‘+’ cannot be applied to types ‘Number’ and ‘Number’ const foo = (a:Number,b: Number) => { return a+b; } So what’s wrong with the above code .Type of a and b should be number and not Number. // ## Solution const foo = (a:number,b: number) => { return a+b; } Number in typescript is a constructor which creates Number objects. [Read More]

Remove Object Property | JavaScript | Object Destructuring

How to Remove Object Property Without Using Delete Operator ? const obj = { name : 'Roy', country : 'India', region : 'Delhi' } Object Destructuring can be used to delete a property from the above JavaScript object. Suppose you want to remove region property. You can destrcuture the obj object into two objects. const {region, ...otherInfo} = obj; // otherinfo - {name: 'Roy', country: 'India'} Here otherInfo is your object without region. [Read More]