In this tutorial, we will learn how to get the tangent of a number in JavaScript. The tangent of an angle is defined by the ratio of the length of the opposite side to the length of the adjacent side. It can also be defined as the ratio of sine and cosine function of an acute angle where the value of cosine function should not be zero. Mathematically, π‘πππ=πππππ‘β ππ π‘βπ πππππ ππ‘π π πππ / πππππ‘β ππ π‘βπ ππππππππ‘ π πππ also, tanΞΈ=(π πππ ππ π‘βπ πππππ π)β(πππ πππ ππ π‘βπ πππππ π) Where π = acute angle in radian The tangent of ... Read More
In this tutorial, we will learn how to get the number of forms in a document using JavaScript. Since different methods are used to create forms in an HTML document, it might get tricky to get the number of forms present. However, you can use some methods to count the forms created without the form tag. Using the length Property The most widely accepted method to create forms in HTML documents is using the tag. Some websites also use tags to create forms in the document. Hence, we will discuss the method to get the number of forms ... Read More
In this tutorial, we will learn how to get the natural logarithm of a number in JavaScript using Math.log() and Math.LN methods Since finding out the natural logarithm of a number through calculation is difficult, the methods like Math.log() and Math.LN is considered useful in JavaScript. You can use these methods not only in finding the length of a number in JavaScript but also while creating a calculation method for a number. Using the Math.log() Method The natural logarithm method is used to find a logarithm of a number with the base E. Compared to Math.LN method, while using Math.log() ... Read More
In this tutorial, we will learn how to get the length of the string in JavaScript. While writing any string in JavaScript, we might need to know the number of characters present in it. By knowing an easy method to calculate the length of a string in JavaScript, we can increase or decrease the words and phrases. There are different ways to get the length of a string, but the easiest way is to use the length property of the string. Letβs discuss the different approaches in detail. Using the string.length Property If you want to use a method ... Read More
In this tutorial, we will discover how to get the port number of the href attribute of an area in JavaScript. An area is a tag in JavaScript. This tag is written as . This tag denotes an area inside an image map. This tag has no closing tag. So in HTML, this is an empty tag. In XHTML, this tag must be closed correctly. An image map is also another tag. This tag is written as . An image map contains an image with clickable or active areas. The area tag comes inside the map tag. This tag ... Read More
If you've been keeping up with the JavaScript world in the last few years, you've probably heard of the concept of a "flux" architecture. In a nutshell, flux is a pattern for managing data flow in applications. It was originally designed for use with React, but it can be used with any other JavaScript framework. There are a few different ways to implement flux, but they all share a few key componentsβ DispatcherΒ β This is a central object that is responsible for managing all data flow in the application. All updates start with the dispatcher. StoresΒ β These are objects ... Read More
In JavaScript, an object can be "flattened" by creating a shallow copy of it. This is useful for creating a snapshot of an object, but can cause problems if the object is later modified. If you need to unflatten an object, you can use the paths for keys to restore the original structure. Using Paths for Keys When an object is flattened, the keys are concatenated into a single string. You can use this string to unflatten the object by creating an object with the same keys and values. For example, consider the following object.var obj = { ... Read More
In JavaScript, an object can be created by using curly braces {}. This is called an object literal. An object literal can contain properties and methods. What is Flattening? Flattening is the process of reducing an object to a singleβdepth object. In other words, all the properties and methods of the object are contained within a singleβdepth object. How to Flatten an Object? There are various ways to flatten an object. Using for...in loop The for...in loop can be used to iterate over the properties of an object. For each property, we can add it to a new object. Below ... Read More
Frame by frame animation is a technique used in animation to produce motion by displaying a series of static images which are sequentially displayed. The appearance of motion is achieved by displaying the images in rapid succession. The followings are needed before we go to create the frame by frame animationβ A series of images (frames) A web page with CSS and JavaScript Approach The process of creating frame by frame animation using CSS and JavaScript is relatively simple. STEP 1 β First, you need to create a series of images (frames) that you want to be displayed ... Read More
In this tutorial, we will learn how to create Expanding Cards using HTML, CSS and JavaScript. We will also learn how to use some additional CSS properties to make our expanding cards more attractive. What are Expanding Cards? Expanding cards are a type of card that can be expanded to reveal more content. They are commonly used to display additional How to create Expanding Cards using HTML, CSS and JavaScript? To create expanding cards, we will need to use the following HTML elementsβ The card container element: This will be the element that will contain all of our cards. ... Read More