In this tutorial, we will discuss how we can return the pixel depth of the screen in JavaScript. There is a property in JavaScript name pixel depth with the help of this property we can quickly return the pixel depth of the screen’s color. This pixel depth property returns the screen’s color depth in bits per pixel, and this property is read-only means (A property's value can be accessed, but it cannot be given a value. or we could state that it cannot be assigned to or overwritten). Basically, we are returning how many bits are used to store a ... Read More
In this tutorial, we will explore how we can find out the number of bits that are used to display a single color on the screen of our device using JavaScript. JavaScript has many inbuilt functions that allow us to get information about the various properties of the display screen. We’ll be using one such function to accomplish the task mentioned above. As discussed in the previous section, we want to find out the exact number of bits that are used to display a particular color on the user’s display screen by using JavaScript. Before we can access the number ... Read More
In this tutorial, we will explore the methods by which we can repeat a string a certain number of times, again and again, to make a new string in JavaScript. There are many scenarios where we may want to make a new string which is just another string repeated ‘x’ number of times and we will see how to achieve that easily using inbuilt methods provided by JavaScript. We want to create a new string which is just another string copied some number of times. Although we can accomplish this task manually by using a for loop or a while ... Read More
In this tutorial, we will explore how we can replace a particular sub string in a string by using regular expressions in JavaScript. Sometimes we may want to replace a recurrent sub string in a string with something else. In such cases, regular expressions can be beneficial. Before using them to solve our current problem, let us see what regular expressions exactly are. Regular expressions are basically a pattern of characters that can be used to search different occurrences of that pattern in a string. Regular expressions make it possible to search for a particular pattern in a stream of ... Read More
This tutorial will teach us how to replace all occurrences of a string in JavaScript which mean by the end of the tutorial we will learn to detect a given type of substring from the given string and replace it will another given string by the user. To replace all occurrences of a string in JavaScript we have three methods which we are going to see in this tutorial, they are: splitting the string into an array and then joining it back by adding replacement in gaps, with the global regular expression using the replace() method, and at last we ... Read More
In this tutorial, we will explore the different ways by which we can replace all dots in a string using JavaScript. It is possible to remove all occurrences of dots in a string manually by running a for loop, but JavaScript provides many functions by which we can accomplish the same task very easily. This is precisely what we will discuss in this article. The two most popular methods by which we can replace all dots in a string using JavaScript are − Using the replaceAll() method in JavaScript JavaScript strings have a method called replaceAll(), to which we can ... Read More
This tutorial teaches us how to remove the text part between two parts of a string with JavaScript, basically, we are given two ends that can be a string or a character and we have to remove the string lying in between them. In this tutorial, we are going to use the regular expression or JavaScript Regex to remove the text between two characters. We are going to use the replace() function of JavaScript. Syntax Let’s see the syntax of removing part of a string in between two characters or sub-strings of a given string using JavaScript Regex − var ... Read More
This tutorial teaches us how to remove the options from a dropdown list using JavaScript. Usually, this is not frequent that users get the option to remove any option from the dropdown list but this is possible if the option is provided by the programmer. If the programmer wants to provide the option to remove the dropdown then in JavaScript it is possible with the help of the remove() method. Using the DOM user can select the option to remove and by providing a function it could be passed to the remove method which will remove it. Let’s look into ... Read More
In this tutorial, we will explore how we can remove leading zeroes from any number in JavaScript. JavaScript removes leading zeroes from an integer variable automatically, but this is not the case when we consider strings in JavaScript. It is possible that a string in JavaScript which represents a numerical value may contain leading zeroes. These leading zeroes may cause problems when we try to perform any operation on the numerical value the string represents. This is why we will explore the ways by which we can remove the leading zeroes from a number, expressed as a string in JavaScript. ... Read More
This tutorial will discuss how to write swift program to print numeric hourglass pattern. Numeric pattern is a sequence of numbers which is used to develop different patterns or shapes like pyramid, rectangle, cross, etc. These numeric patterns are generally used to understand or practice the program flow controls, also they are good for logical thinking. To create a numeric hourglass star pattern we can use any of the following methods − Using nested for loop Using init() Function Using stride Function Here we divide the numeric hourglass pattern in two portions upper half portion and ... Read More