Front End Technology Articles - Page 508 of 860

How to make your code faster using JavaScript Sets?

Arnab Chakraborty
Updated on 23-Aug-2022 07:20:29

1K+ Views

While writing code, we always try to make our code easier to read, less complex, more efficient, and smaller in size. For that, we follow several methodologies which make our code efficient. In this article, we shall focus on some techniques based on Javascript sets to perform certain array-like or collection-based applications which will run faster and the code will also be concise. Let us focus few use cases. How sets are different than arrays and the benefits of using sets over an array Arrays are indexed collections where each element is associated with a specific index. On the other ... Read More

Javascript search for an object key in a set

Disha Verma
Updated on 13-Mar-2025 13:09:45

440 Views

In JavaScript, to search for an object key in a Set, you need to understand how Sets store values and how objects behave in JavaScript. JavaScript Sets are useful objects that store unique values, making them excellent for handling distinct data. In this article, we'll explore different ways to search for an object key in a Set. JavaScript Set A Set in JavaScript is a collection of unique values. Values like numbers and strings can be compared directly, but objects are stored by reference. This means that even if two objects have the same properties, they are still seen ... Read More

How to know whether a value is searched in Javascript sets?

Arnab Chakraborty
Updated on 23-Aug-2022 06:54:47

184 Views

In javascript, we may use some sets to hold a few objects. Sometimes we want to check whether an element is present inside a set or not. In this article, we will see different techniques to check whether an element is inside a given set or not.p> A trivial method using for loop At first, we can search for an element by manually picking an element and checking whether it is the same as the key element or not. If so then simply return true, otherwise after completing all elements return false. Examples HTML ... Read More

HTML max Attribute

AmitDiwan
Updated on 17-Sep-2019 09:15:03

129 Views

The max attribute of the element is used to set the upper bound for . However, the element is used to measure data with a give range like water impurity level and it is set using the min and max attribute.SyntaxFollowing is the syntax −The num above is a number in floating-point that sets the max attribute of the element.ExampleLet us now see an example to implement the max attribute of the element − Live Demo Water Levels Impurity Level TDS Level OutputThis will produce the following output −In the above example, ... Read More

Ways to create a Set in JavaScript?

Ayush Gupta
Updated on 18-Sep-2019 12:01:15

164 Views

A set is an abstract data type that can store certain values, without any particular order, and no repeated values. It is a computer implementation of the mathematical concept of a finite set. Unlike most other collection types, rather than retrieving a specific element from a set, one typically tests a value for membership in a set.Ways to create a set in js−1. Using empty Set constructorlet mySet = new Set(); mySet.add(1); mySet.add(1); console.log(mySet)OutputSet { 1 } 2. Passing an iterable to the constructorThe set constructor accepts an iterable object(list, set, etc) using which it constructs a new set.Examplelet mySet ... Read More

HTML Design Form

AmitDiwan
Updated on 17-Sep-2019 09:07:50

5K+ Views

HTML Forms are required, when you want to collect some data from the site visitor. For example, during user registration you would like to collect information such as name, email address, credit card, etc.A form will take input from the site visitor and then will post it to a back-end application such as CGI, ASP Script or PHP script etc. The back-end application will perform required processing on the passed data based on defined business logic inside the application.The tag is used in HTML to create a form and various form element like input, textarea, etc is included in ... Read More

HTML DOM Anchor Object

AmitDiwan
Updated on 17-Sep-2019 09:01:23

189 Views

The element is used in HTML to create hyperlinks along with href attribute. The anchor object represents this element.ExampleIn the below example, we will learn how to access an anchor object − Live Demo Demo Heading Google Display the link Link gets displayed here    function display() {       var a = document.getElementById("myid").href;       document.getElementById("demo").innerHTML = a;    } OutputThis will produce the following output −

What are javascript sets?

Ayush Gupta
Updated on 18-Sep-2019 11:57:00

213 Views

A set is an abstract data type that can store certain values, without any particular order, and no repeated values. It is a computer implementation of the mathematical concept of a finite set. Unlike most other collection types, rather than retrieving a specific element from a set, one typically tests a value for membership in a set.You should use sets, whenever you want to store unique elements in a container for which the order doesn't matter and you mainly want to use it to check for membership of different objects. Sets are also useful when you want to perform operations ... Read More

How to duplicate Javascript object properties in another object?

Abdul Rawoof
Updated on 02-Sep-2022 12:10:12

2K+ Views

In JavaScript, objects are the collection of a key value pairs. The properties of the object are the keys and is denoted with a string. The value of the key is the value of the property of the given object. In JavaScript, the objects can be copied to other by many ways in which some of them are − Using spread operator(…) The spread operator in JavaScript is used to copy the values of the original given object to a new object. This operator is represented by three dots(…). Example 1 This example demonstrates how spread operator is used to ... Read More

HTML DOM Anchor hostname Property

AmitDiwan
Updated on 17-Sep-2019 08:58:40

129 Views

The HTML DOM Anchor hostname property returns only the hostname of the URL. It returns the domain name.SyntaxFollowing is the syntax to set the hostname property −anchorObj.hostname = hostnameAbove, the hostname is the hostname of the URL.SyntaxFollowing is the syntax to return the hostname property −anchorObj.hostnameExampleLet us now see an example to implement the DOM Anchor hostname property − Live Demo Company Our Team Display Anchor Part Display Host Part Display Hostname    function display() {       var a = document.getElementById("mylink").hash;       document.getElementById("myid").innerHTML = a;    }    function display2() {     ... Read More

Advertisements