javascript

javascript

3 different ways to remove the last character of a string in JavaScript

In this post, I will show you three different JavaScript programs to remove the last character of a string. For example, if the string is hello1, it will print hello. Try to run these examples and drop one comment below if you have any queries.

Read
javascript

How to check if an object is empty or not in JavaScript

In this tutorial, we will learn how to check if an object is empty or not in Javascript. This is one of the important things to learn if you are developing any javascript application. You can't be sure that any object you are receiving either from an API or from a function will be non-empty always. So, instead of breaking your code, you should always check if an object is empty or not. This is a good coding practice and we should follow it on any programming language, not only in Javascript.

Read
javascript

JavaScript find if an object is in an array of object

Finding out if an object is in an array or not is little bit tricky. indexOf doesn't work for objects. Either you need to use one loop or you can use any other methods provided in ES6. Loop is not a good option. JavaScript provides a couple of different methods that makes it more easier.

Read
javascript

Different ways in JavaScript to check if all elements of one array are in a second array

JavaScript comes with a couple of different array methods. You don't have to loop through each elements of an array to check if they are in a second array. In this post, I will show you different ways to check if all elements of an array is in another way or not. in a second array

Read
javascript

JavaScript program to find out the area and perimeter of a circle

This is a JavaScript practice problem. We will learn how to find the area and perimeter of a circle in JavaScript. We will use one class to solve this problem.With this program, you will get familiar with JavaScript class and object.JavaScript Math class and how to use constants of Math class in a JavaScript program.

Read
javascript

JavaScript find the sum of all odd numbers smaller than a number

Find the sum of all odd numbers smaller than a number in JavaScript in three different ways. We will use a for loop, while loop and loops with jumping the numbers to find the required sum.

Read
javascript

JavaScript join, toString example to convert array to string

JavaScript provides two methods join() and toString() to convert array elements to a string with comma-separated values. toString() method is inherited from the Object class. It was introduced in ECMAScript 5. Both methods actually return the same string value. One more thing is that we can change the separator in the join method. Let me show you with examples :.

Read
javascript

Convert date to ISO 8601 and UTC in JavaScript

If you are working with date, you should always get aware of these two terms- ISO and UTC. ISO 8601 is a standard used for date-time representation. The way date is represented, the date separators are not the same for all countries. Using ISO 8601, we can convert all times to a similar format. So, if we store the ISO date on the database, it can be converted and represent as we like on the frontend.

Read
javascript

JavaScript copyWithin() method example

Javascript copyWithin() method is used to copy a portion of one array in the same array in a range. copyWithin doesn't modify the array size. It just copies the elements to separate indices. This method is useful if you want to copy one part of the array or subarray to another part.

Read
javascript

How to trim a string in JavaScript with examples

Trimming is used to remove whitespace characters from a string. Javascript provides us different methods to remove whitespaces from the start, end and both sides of a string. Whitespace is any whitespace character like tab, space, LF, no-break space, etc.

Read