Found 6710 Articles for Javascript

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

What is setInterval() method in JavaScript?

vineeth.mariserla
Updated on 05-Aug-2019 11:53:58

371 Views

setInterval()This is one of the many timing events. The window object allows code to execute at every certain interval of time. This object has provided SetInterval() to repeat a function for every certain amount of time. It takes two parameters as arguments. One is the function and the other is the time that specifies the interval after which the function should be repeated.syntaxwindow.setInterval(function, milliseconds, param1, param2, ...));This method can also take other parameters and can add it to the function.Example-1In the following example, setInterval() method is defined and a time interval of 3000 millisecs or 3 seconds is declared. Therefore the function provided ... Read More

What is setTimeout() Method in javascript?

vineeth.mariserla
Updated on 05-Aug-2019 11:10:33

462 Views

 setTimeout()This is one of the many timing events. The window object allows the execution of code at specified time intervals. This object has provided SetTimeout() to execute a function after a certain amount of time. It takes two parameters as arguments. One is the function and the other is the time that specifies the interval after which the function should be executed.syntaxwindow.setTimeout(function, milliseconds);Example-1In the following example, the time passed to the setTimeout() function is 2 seconds. Therefore the function will be executed after two secs and display the output as shown.Live Demo wait 2 seconds.    setTimeout(function(){   ... 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

"extends" keyword in JavaScript?

Manisha Patil
Updated on 23-Aug-2022 13:37:33

1K+ Views

In JavaScript, you may extend both classes and objects with the extends keyword. It is frequently used to build classes that are children of other classes. In addition to built-in objects, customized classes can also be subclass using the extends keyword. The classes serve as the blueprint for a real-world item so that we may easily change, access, and utilise them in programming. It is specified to establish an abstract data type to hold a specific sort of information together with the methods for manipulating that information. You use the extends keyword to use class inheritance. Any constructor with the ... Read More

Using a JavaScript object inside a static() method?

vineeth.mariserla
Updated on 02-Jul-2020 12:46:34

101 Views

Actually, the result will be in vain when we try to use an object inside a static method. But when the object is sent as a parameter, we can access the object. let's discuss it in a nutshell.Example-1In the following example, we tried to use the object "myComp" directly rather than sending it as a parameter, therefore, we get no result. If we open the browser console we will get an error that is "myComp.comp() is not a function". To get the actual result we have to send the object as a parameter as shown in Example-2    class ... 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

Advertisements