Found 6710 Articles for Javascript

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

Lokesh Yadav
Updated on 08-Dec-2022 08:13:41

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
Updated on 08-Dec-2022 08:12:01

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 convert a value into Boolean in JavaScript?

Lokesh Yadav
Updated on 08-Dec-2022 08:10:12

904 Views

In this article we are going to discuss how to convert a value into Boolean in JavaScript. In JavaScript programming we sometimes need values like these ‘YES / NO, ‘ON / OFF’, ‘TRUE / FALSE’. So, JavaScript provides Boolean() method, which helps us to convert a value into Boolean. A Boolean is a value that can return either true/false. There are two ways using which we can convert values into Boolean. One way is to use Boolean() method and the other way is to use the !! notation. Let’s understand this concept better with the help of the examples further ... Read More

What is the use of ()(parenthesis) brackets in accessing a function in JavaScript?

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26

506 Views

The ()(parenthesis) brackets play an important role in accessing a function. Accessing a function without () will return the function definition instead of the function result. If the function is accessed with () then the result can be obtained.Without ()ExampleIn the following example, the function is accessed without () so the function definition is returned instead of the result as shown in the output.Live Demo function toCelsius(f) { return (5/9) * (f-32); } document.write(toCelsius); Outputfunction toCelsius(f) { return (5/9) * (f-32); ... Read More

How to Find the action Attribute and method of a Form in JavaScript?

Lokesh Yadav
Updated on 27-Jan-2025 12:06:11

3K+ Views

In this article we are going to learn how to find the action attribute and method of a form with suitable examples in JavaScript. In HTML, there is  elements which has few attributes: input, label, text area, select, name, target. The action and method attributes of the form are used to return those values. The action attribute also specifies where to send the form data when form is submitted. To get a better idea of this concept, let’s look into JavaScript examples where we achieved the given task using action attribute and also with method attribute. Using action ... Read More

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

Lokesh Yadav
Updated on 08-Dec-2022 08:04:49

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
Updated on 08-Dec-2022 08:03:14

424 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
Updated on 08-Dec-2022 08:01:44

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 get the cookies associated with a document in JavaScript?

Lokesh Yadav
Updated on 08-Dec-2022 08:00:28

657 Views

In this article we are going to learn how to get the cookies associated with a document in JavaScript. The cookies property present in the Document interface is used to return the cookies associated with a Document in JavaScript. The Cookies are small strings of data that is present in the form of name=value pairs inside a browser. Each cookie is delimited by a ‘;’. Cookies are used for client-server applications. Cookies have an expiration date. They have a size limit of 4KB. To get a better understanding of this concept, let’s look into the examples further in this article. ... Read More

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

Lokesh Yadav
Updated on 08-Dec-2022 07:58:49

492 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

Advertisements