Found 10483 Articles for Web Development

HTML DOM Anchor rel Property

AmitDiwan
Updated on 20-Feb-2021 06:35:51

166 Views

The HTML DOM Anchor Rel property returns the rel attribute of a link. The rel attribute describes the association between the running document and the linked document.SyntaxFollowing is the syntax to −a) Return the rel property −anchorObject.relb) Set the rel property &minusanchorObject.rel = "value"ExampleLet us see an example of the HTML DOM anchor rel property −Live Demo Example Anchor Rel Property Click on the button Click me!    function display() {       var docs = document.getElementById("anchorExample").rel;       document.getElementById("show").innerHTML = docs;    } OutputThis will produce the following output −Click ... Read More

How to check whether a number is finite or not in JavaScript?

Lokesh Yadav
Updated on 09-Dec-2022 05:31:09

410 Views

In this article, we are going to discuss how to check whether a number is finite or not with suitable examples in JavaScript. To check whether a number is finite or not in JavaScript, there is an inbuilt method which is isFinite() method. This method returns true if the number is a finte number. If the number is not a dfinite number, this method returns false. To get a better understanding let’s look into the syntax and usage of isFinite() method in JavaScript. Syntax The syntax to check whether a number is finite or not is − isFinite(value) Where, ... Read More

Get data from sessionStorage in JavaScript?

Lokesh Yadav
Updated on 09-Dec-2022 05:29:56

14K+ Views

Let us discuss how to get data from with suitable examples in Javascript. The sessionStorage Object is a window object property that exists in all modern browsers. Any data kept in sessionStorage is linked to the page's protocol, hostname, and port. The session storage is unique for every window. The sessionStorage object is a method that really helps to retain data on the client in a safe manner. To access the elements from session storage in javascript, we use getItem() method which helps us to access elements that are stored in the session storage object. The getItem() method belongs to ... Read More

Retrieve element from local storage in JavaScript?

Lokesh Yadav
Updated on 09-Dec-2022 05:28:21

7K+ Views

Let us discuss how to retrieve element from local storage with suitable examples in Javascript. To retrieve elements from the local storage in Java Script, we use getItem() method which helps us to access elements that are stored in the local storage object. The getItem() method belongs to the storage object. It can be a local storage object or a session storage object. The data that is stored inside the local storage is non-volatile storage. Even if we run out of the session time in a browser or if we close the browser, the data gets stored in the local ... Read More

Weekday as a number in JavaScript?

Lokesh Yadav
Updated on 09-Dec-2022 10:19:11

4K+ Views

In this article, we are going learn about the weekday as a number in JavaScript with appropriate examples. To get the weekday as a number, JavaScript has provided getDay() method. The getDay() is a method from Date object. The getDay() method returns a value between 0 to 6. For example, Sunday = 0, Monday =1, Tuesday =2, Wednesday = 3 and so on. To get a better understanding, let’s look into the syntax and usage of getDay() method in JavaScript. Syntax The syntax for getDay() method is − dateObject.getDay(); Where, dateObject is an object created from date. This method ... Read More

Getters and setters in JavaScript classes?

Lokesh Yadav
Updated on 09-Dec-2022 05:26:33

6K+ Views

In this article we are going to discuss about the getters and setters in JavaScript classes with suitable examples in JavaScript. In JavaScript, getters and setters are the methods that are used to get or set the value for properties. When using getters and setters, you can ensure higher data quality. Getters and Setters provide a simplified syntax for an object's properties and methods. Getters and Setters are used for Data Encapsulation. To add getters and setters in the class, use the get and set keywords. To get a better understanding let’s look into the syntax and usage of both ... Read More

Another method other than a constructor in a JavaScript class?

Lokesh Yadav
Updated on 09-Dec-2022 05:16:43

244 Views

In this artcle we are going to learn another method other than a constructor in a JavaScript class with suitable examples in JavaScript The Constructor is used to create and initialize an instance of a class i.e., object. The constructor's job is to build a new object and set values for any attributes that already exist on the object. Every class has a default constructor. If we don’t provide our own constructor, then the default constructor will be incoked. Let’s understand this concept in a better way with the help of suitable examples further in this article. Syntax The syntax ... Read More

How to convert JavaScript objects to primitive data types manually?

Lokesh Yadav
Updated on 09-Dec-2022 05:13:04

644 Views

In this article we are going to discuss how to convert JavaScript objects to primitive data types manually with suitables examples in JavaScript. Primitive data types are nothing but a string, number, boolean, etc. To convert objects to primitive data types, javascript has provided some methods such as toString(), toDateString(), valueOf(), etc. Using these methods javascript objects can be easily converted to primitive data types. Using the toString() method This method returns a string value representing the string format of the given object. The syntax to convert a javascript object into a primitive date type (string, in this example) is ... Read More

How to convert a JSON string into a JavaScript object?

Lokesh Yadav
Updated on 09-Dec-2022 05:11:36

3K+ Views

In this article we are going to discuss how to convert a JSON string into a JavaScript object with suitables examples in JavaScript. There are two possible ways to convert a JSON string into a Javascript object – eval() and parse(). The usage of eval() method is unsafe and not preferred. It is vulnerabable to hackers. The parse() method is preferred in general anytime. The typical application for JSON is Data transfer to and from a web server. The data that has been sent from a server is always a JSON string. Using JSON.parse(), we can convert the JSON string ... Read More

How to convert a value to a number in JavaScript?

Lokesh Yadav
Updated on 08-Dec-2022 08:18:08

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

Advertisements