Found 6685 Articles for Javascript

How to create a function from a string in JavaScript?

Prerna Tiwari
Updated on 02-Mar-2023 16:06:43

1K+ Views

Creating a function from a string in JavaScript can be helpful in situations when you need to generate a function dynamically at runtime or when you have a string that contains the code for a function you wish to execute. The ability to construct a function from a string is a useful functionality of JavaScript that allows dynamic function creation at runtime. The eval() function and the new Function() function Object() [native code] are the two most popular methods for doing this, although both have significant security flaws. The Function.prototype.constructor is a safer option even though it is ... Read More

How to convert a plain object into ES6 Map using JavaScript?

Prerna Tiwari
Updated on 02-Mar-2023 16:03:11

274 Views

There are many ways to convert a plain object into an ES6 Map in JavaScript. The simplest and most effective way is using the Object.entries() function and the Map() constructor. In contrast, the more flexible alternatives include Object.keys() and Array.prototype.forEach() and the for...in loop and Map() function method. A Map in ES6 is a collection of key-value pairs. Here we can use any type of object as a key, including primitive data types like strings and numbers. The values in the map can be any type of object. The main difference between a Map and an object is that ... Read More

How to convert a pixel value to a number value using JavaScript?

Prerna Tiwari
Updated on 02-Mar-2023 15:57:49

3K+ Views

Converting pixel values to number values in JavaScript is a simple task that can be accomplished using built-in functions such as parseInt(), parseFloat(), Number() and also string method replace(). Each method has its own advantages and disadvantages and the best method to use will depend on the specific requirements of your project. When positioning and styling items on a web page, it's sometimes required to work with both pixel and numeric values in web development. To execute computations or operations on a value, for instance, you might need to convert a pixel value, such as "100px, " to a ... Read More

How to convert a number into an array in JavaScript?

Prerna Tiwari
Updated on 02-Mar-2023 15:43:42

5K+ Views

In JavaScript, there are many built-in methods that can convert a number into an array. The simplest one is to the split() method. We can also use the map(), reduce(), or form() methods to perform the task. Some of the most popular methods for converting a number into an array are discussed in this article, along with examples of when and how to apply each technique. Now, the question will be, why there can be a need to convert a number into an array? Then the reason could be splitting a phone number into its individual digits or breaking own ... Read More

Form required attribute with a custom validation message in HTML5

Prerna Tiwari
Updated on 02-Mar-2023 15:37:53

16K+ Views

HTML5 includes a number of built-in form validation features that allow developers to easily add validation to their forms. One of these features is the "required" attribute, which specifies that an input field is required and must be filled out before the form can be submitted. The “required” attribute is a boolean attribute. If any input field with the “required” attribute is present in the form, then this field must be completed before submitting the form. If that particular field is left blank before submitting the form, the user will see an error message from the browser informing ... Read More

Introduction to Anime.js

Prabhdeep Singh
Updated on 02-Mar-2023 15:26:19

1K+ Views

Anime.js is a lightweight JavaScript library with a straightforward, effective API. It functions with JavaScript objects, CSS, and DOM elements and also Anime.js is easy to use. Traditionally, we make animations by gradually modifying the styling of an element. Such movements are possible with JavaScript, but even the simplest animations are difficult and time-consuming to develop. Anime.js makes animation easier by offering a variety of tools. It offers capabilities to regulate the timing and user inputs and supports many animations running concurrently on the same object. The majority of popular browsers also support Anime.js. Installation Part of Anime.js ... Read More

Introduction and Installation of Svelte

Prabhdeep Singh
Updated on 02-Mar-2023 15:33:43

443 Views

Svelte is the new method to create web applications, it can be used from a small part of the code to the complete page web application. Svelte is not a framework, it is a compiler that is much faster as compared to the other libraries of JavaScript such as Angular JS, Vue.js, and React JS. The main purpose of the Svelte is to create reactive web applications and provides the functionality that if any change comes in the data, that will reflect on the page rapidly and will not take much time. Introduction to Svelte As we have seen in ... Read More

Introduction and Installation of Nightmare.js

Prabhdeep Singh
Updated on 02-Mar-2023 15:14:58

380 Views

Nightmare is a high-level automation library offered by segment. It's a good option for smoke test automation because it can perform all of the text inputs, clicks, and visual checks that a person can. It operates as a headless browser using Electron. In this article, we will discuss Nightmare.js in detail and the installation of Nightmare.js. Introduction to Nightmare.js Segment offers Nightmare, a sophisticated browser automation library. The objective of this Nightmare is to mimic user activities (such as goto, type, click, etc.), rather than using heavily nested callbacks, to expose a few basic methods with an API that ... Read More

Interesting facts about JSON

Prabhdeep Singh
Updated on 02-Mar-2023 15:10:47

495 Views

JSON stands for JavaScript Object Notation, basically, JSON is frequently used with JavaScript, it was initially meant to be a subset of the JavaScript programming language. However, JSON is a language-independent data format. In this article, we are going to learn about JSON and also their interesting facts with examples. Introduction to JSON When data can be transported and stored in a simple format is called JSON, or JavaScript Object Notation. Arrays, objects, names and value pairs, and other data types can all be found in JSON. The format uses quotation marks, brackets, parentheses, semicolons, and colons as punctuation. ... Read More

Integer Range in JavaScript

Prabhdeep Singh
Updated on 02-Mar-2023 15:08:48

740 Views

For storing the data there are various types of data types present in each programming language. Data may be in the form of string, character, number, etc. For each type of data type, there is a certain limit of memory allocated to use the memory efficiently for example, the character is a small unit and an integer may be large as compared to the character so it's better to define a character different from the integers. To use the memory efficiently there are various data types created based on the memory they are going to take which leads to ... Read More

Advertisements