Found 8894 Articles for Front End Technology

How to work with document.anchors in JavaScript?

Shubham Vora
Updated on 15-Nov-2022 09:12:14

593 Views

In this tutorial, let us discuss how to work with the document's anchor in JavaScript. Relevant web technologies no longer recommend this property. Some browsers still recommend it for compatibility reasons. The document anchor property is a read-only feature that returns all the anchor tags. The anchor tag represents the start and end of a hyperlink. The anchor tag attributes are name, href, rel, rev, title, urn, and method. All attributes are optional. But a name attribute is mandatory for document anchors to work. Working with anchor’s properties Let us learn to work with an anchor's properties. Users can follow ... Read More

What are the rules to be followed for Object Definitions in JavaScript?

Shubham Vora
Updated on 31-Oct-2022 11:18:39

255 Views

In this tutorial, we will discuss the rules to follow for Object Definitions in JavaScript. JavaScript is an object-oriented scripting language. An object contains many properties. The property consists of a key and a value. The property is known as a method when this value is a function. Predefined objects are available in the browser. We can also define our objects. A real-life example of an object is a cup. The color, design, weight, and material are the main properties of a cup. The object name and the property name are case-sensitive. To define a property, we need to assign ... Read More

How to perform numeric sort in JavaScript?

Shubham Vora
Updated on 14-Sep-2022 13:39:30

11K+ Views

In this tutorial, we will learn how to perform the numeric Sort in JavaScript. We can arrange the given numerical values by numerical sorting into ascending or descending order In JavaScript, we use the sort () method to sort numerical values. This method sorts the arrays of numbers, strings, and objects. It sorts the elements of an array and changes the order of the original array's elements. The array elements are cast to strings to determine the order and then compared and sorted. arr.sort() Where arr is the array of numeric elements that need to be sorted, this method ... Read More

How to get the value of the rel attribute of a link in JavaScript?

Shubham Vora
Updated on 14-Sep-2022 09:15:29

2K+ Views

In this tutorial, we will learn how to get the value of the rel attribute of a link in JavaScript. The rel attribute expressed the relationship between the current document or website and the linked document or website. The search engine uses this attribute to get more information about the link, so it is important for the SEO of the website. The rel attribute can have different values like alternate, author, external, nofollow, etc.; each value means different information about the link. For example, ‘alternate’ means the link represents an alternate version of the current document. Using document.getElementById() Method In ... Read More

Are both addition and concatenation same in JavaScript?

Sravani Alamanda
Updated on 08-Dec-2022 08:43:53

2K+ Views

We can't say whether both are the same or both are different. In some cases, addition and concatenation will have the same result, but in some cases, they will be different. It is completely based on the type of variables. We will see it in detail below We use the + operator for addition and the concat() method for concatenation in JavaScript. In some cases, both the + operator and the concat() method returns the same result. Adding and concatenating two strings using the + operator and the concat() method returns the same result. We can also apply the ... Read More

Is it a good practice to end switch with defaults in JavaScript?

Shubham Vora
Updated on 31-Oct-2022 11:54:20

639 Views

In this tutorial, we will learn if it is a good practice to end switch with defaults in JavaScript. In JavaScript, we generally use the if or if-else statements if we need to check any conditions. Still, if we need to check multiple conditions for an expression, it becomes very complex and unorganized, so we use the switch statements for that situation. The switch statement compares the value of an expression to a series of case clauses, then executes statements after the first case clause that matches the value, and so on, until a break statement is met. If no ... Read More

What are the best practices to be followed while using JavaScript?

Shubham Vora
Updated on 15-Nov-2022 10:50:56

92 Views

In this tutorial, we will learn the best practices to follow while using JavaScript. JavaScript is used in almost every website to make it more user interactive. Throughout the years, ECMAScript has released different versions of JavaScript. Each version has enhanced functionalities and new features, so it is important to know the best practices to follow while using JavaScript. The following are the best practices to be followed while using JavaScript − Meaningful Variable and Function Name The variables’ and functions’ names should be meaningful to their uses. In JavaScript, we use the variable to store some data, and the ... Read More

How to get the value of the hreflang attribute of a link in JavaScript?

Shubham Vora
Updated on 14-Sep-2022 09:09:29

642 Views

In this tutorial, we will learn how to get the value of the hreflang attribute of a link in JavaScript. The hreflang is an attribute of a link or anchor tag which specifies the language of the linked document or href attribute. It is used by search engines to understand the link’s language and the targeted geographical location of the website. For better SEO hreflang attribute must be used. A single language or combination of language and region is used as the value of the hreflang attribute. It uses the language code ISO-639-1 and region code ISO-3166-1. For example: If ... Read More

How to remove options from a dropdown list with JavaScript?

Prabhdeep Singh
Updated on 07-Nov-2022 06:01:56

11K+ Views

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

How to show the index of the selected option in a dropdown list with JavaScript?

Abhishek Kumar
Updated on 21-Sep-2022 07:48:25

10K+ Views

We use the selectedIndex property in JavaScript to show the index of the selected option in a dropdown list. We use the id of the dropdown list to access the element using JavaScript and then call selectedIndex on it to get the index of the selected option in the dropdown list. Dropdown lists are an important part of user interface utility. It is a list of options from which one or multiple options can be selected by the user. These responses to these dropdown lists are then collected and the required course of action is taken by the user. A ... Read More

Advertisements