Number of Elements a Particular Tag Contains in JavaScript

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

1K+ Views

In this article we are going to learn about the number of elements a particular tag contains in JavaScript with suitable examples. There are two possible ways to find the number of elements a particular tag contains in JavaScript. One of the possible way is to use the existing property childElementCount and the other way is to use the length property of JavaScript. To understand better, Let’s look into the examples which achieved the above task by using childElementCount and length property of JavaScript. Using the childElementCount property The childElementProperty will return the number of elements a particular id tag ... Read More

Built-in JavaScript Constructors

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

1K+ Views

In this article, we are going to discuss about the Built-in JavaScript constructors with appropriate examples in JavaScript. Javascript has provided some built-in constructors for native objects. These built-in functions include Object(), String(), Boolean(), RegExp(), Number(), Array(), Function(), Date(). Note We cannot include Math object in those built-in constructors because Math is a global object. The 'new' keyword cannot be used with Math. Let’s understand this concept in a better way with the help of examples further in this article. Example 1 This is an example program to illustrate about the inbuilt constructor String(). ... Read More

Add a Property to a JavaScript Object Constructor

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

869 Views

In this article, we’ll go over how to add a property to a JavaScript object constructor in JavaScript with appropriate examples. Adding a property to an object constructor is different from adding a property to a normal object. If we want to add a property, we have to add it in the constructor itself rather than outside the constructor whereas we can add anywhere in a normal object. To get a better understanding of the given task, let’s look into the syntax and usage of the constructor in JavaScript. Syntax The syntax for a constructor is − Constructor(); // No ... Read More

Add a Method to a JavaScript Object

Lokesh Yadav
Updated on 09-Dec-2022 05:37:08

7K+ Views

In this article, we’ll go over how to add a method to a JavaScript object in JavaScript with appropriate examples. A JavaScript object is an entity which has properties. A property can be a variable or a method which define state and behavior of the object. A method is a property of an object that adds behavior to an object. We can add a method to a JavaScript object using object prototype. All JavaScript objects get their attributes and methods from a prototype. Let’s understand this concept better with the help of examples further in this article. Syntax The syntax ... Read More

Encode a String in JavaScript

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

26K+ Views

In this article we are going to learn how to encode a string in JavaScript with appropriate examples. Encoding is the process of converting from one data format to another format. In computer science terms, encoding is the process of converting a text into a cipher text. Encoding is different from the Encryption process. The difference between encoding and encryption is where the encoding is used to keep data usable and data confidentiality is maintained by encryption. Encoding does not use a key for encoding process whereas for encryption there should be a key for encryption process. The methods that ... Read More

Check Whether a Number is Finite in JavaScript

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

416 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

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

255 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

Advertisements