Javascript Articles

Page 213 of 534

Are both addition and concatenation same in JavaScript?

Sravani Alamanda
Sravani Alamanda
Updated on 08-Dec-2022 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

How to convert a value to a number in JavaScript?

Lokesh Yadav
Lokesh Yadav
Updated on 08-Dec-2022 4K+ Views

In this article we are going to discuss how to convert a value to a number in JavaScript. JavaScript has introduced Number(), parseInt(), parseFloat() methods to convert a value into a number and also we can achieve it by using (+) unary operator. These mentioned methods can convert number strings to numbers and Boolean values to 1's or 0's. Let’s us discuss these above mentioned methods briefly. We’ll discuss the 4 possible ways to convert a value to a number with an example each. Number() parseInt() parseFloat() Unary Opertaor(+) Example 1 The following is an example program to ...

Read More

How to set dynamic property keys to an object in JavaScript?

Lokesh Yadav
Lokesh Yadav
Updated on 08-Dec-2022 3K+ Views

In the following example we are going to learn how to set dynamic property keys to an object in JavaScript. To add dynamic property keys to an object in JavaScript, there are three possible ways. There are three possible ways to set dynamic property keys to an object. The first possible way is to create a key and assign it to the object, second possible way is to set the dynamic property keys to an object using the define property method and the third possible way is to set the dynamic property keys to an object using ES6 method. We ...

Read More

How to access an object value using variable key in JavaScript?

Lokesh Yadav
Lokesh Yadav
Updated on 08-Dec-2022 14K+ Views

In this article we are going to discuss how to access an object value using variable key in JavaScript. An object value can be accessed by a Dot Notation and a Bracket Notation. To get the object value through a variable key, the value or expression inside the bracket notation must match with the existing key name, then it returns a value. The bracket notation, unlike the dot notation can be used with variables. If we are using a variable with bracket notation, the variable must reference a string. Let’s understand this concept better with the help of examples further ...

Read More

How to display the date and time of a document when it is last modified in JavaScript?

Lokesh Yadav
Lokesh Yadav
Updated on 08-Dec-2022 2K+ Views

In this article we are going to discuss how to display the date and time of a document when it is last modified in JavaScript. It is important to know the last updated date and time of a web document, when you read some content on the web, to know whether the web document is latest or outdated. The Document object has lastModified property which returns us the last modified date and time of a document. This is a read-only property. The value of the lastModified property is obtained by the HTTP header from the web server. For people who ...

Read More

How to find the accept-charset and enctype attribute of a form in JavaScript?

Lokesh Yadav
Lokesh Yadav
Updated on 08-Dec-2022 471 Views

In this article we are going to discuss how to find the accept-charset and enctype attribute of a form in JavaScript. In HTML, there is a element which has few attributes − input, label, text area, select, name, target. The accept-charset is used to return the set of one or more encoding types for the HTML document. This attribute also specifies the character encodings that are to be used for the form submission. The enctype is used to specify how the form-data is encoded. Using acceptCharset attribute The acceptCharset attribute in JavaScript will display the acceptable charset values. Syntax ...

Read More

How to find the name and the target of a form in JavaScript?

Lokesh Yadav
Lokesh Yadav
Updated on 08-Dec-2022 1K+ Views

In this article we are going to learn how to find the name and the target of a form in JavaScript. In HTML, there is element which has few attributes: input, label, text area, select, name, target. The name and target attributes of form are used to find those elements in JavaScript. The name attribute is used to return the name of the form. The target attribute is used to check whether the result will open in the same window or new window or new frame, when the form is submitted. The possible values for target are blank, _self, ...

Read More

How to display the domain of the server that loaded a document in JavaScript?

Lokesh Yadav
Lokesh Yadav
Updated on 08-Dec-2022 550 Views

In this following article we are going to learn how to display the domain of the server that loaded a document in JavaScript. To display the domain of the server, we use domain property of the document interface, which returns the domain part of the current document. The domain property will return NULL if the document was created in memory. Attempting to set the domain property of the document interface results in SecurityError. To understand better, let’s look into the syntax and usage of domain property with suitable examples in JavaScript. Using domain property We can get the domain name ...

Read More

How to find the number of links in a document in JavaScript?

Lokesh Yadav
Lokesh Yadav
Updated on 08-Dec-2022 1K+ Views

In this article we are going to discuss how to find the number of links in a document in JavaScript. The DOM property in the JavaScript provides many properties like , , , , , . There are two ways through which we can represent the links in HTML DOM. The DOM object provides links property. The document.links property provides us a collection of and tags inside a document. The document.links property is similar to an array. We can access any property (like href, name, title) of the links using this property. To find the total number of ...

Read More

How to get a particular anchor in a document in JavaScript?

Lokesh Yadav
Lokesh Yadav
Updated on 08-Dec-2022 2K+ Views

In this article we will learn how to get a particular anchor in a document in JavaScript. The Javascript anchor tags follow an array-like structure. When we try to display a particular anchor tag we have to use ,document.anchors.innerHTML method. This method works the same as array methods which are used to display a particular element. To get a better understanding let’s look into the usage and syntax of anchor tag in JavaScript. Syntax The syntax to get a particular anchor tag is shown below. document.anchors[i].innerHTML or document.getElementsByTagName(“a”)[i].innerHTML Example 1 The following is an example program to get a ...

Read More
Showing 2121–2130 of 5,338 articles
« Prev 1 211 212 213 214 215 534 Next »
Advertisements