Front End Technology Articles - Page 541 of 860

What is setTimeout() Method in javascript?

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

472 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

107 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

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

How to access 'this' keyword inside an arrow function in JavaScript?

vineeth.mariserla
Updated on 01-Aug-2019 14:12:25

578 Views

"this" keyword in an arrow functionThe JavaScript 'this' keyword refers to the object it belongs to. In an arrow function, 'this' belongs to a global object. Inside a simple function, there might be chances that 'this' keyword can result in undefined but in an arrow function it results in an exact value.ExampleLive Demo    function Student(fname, grade) {       this.fname = fname;       this.grade = grade;       this.details = function() {          return () => {             document.write(`Hi, I'm ${this.fname} from ${this.grade} grade`);          };       }    } let info = new Student('picaso', 'seventh'); let printInfo = info.details(); printInfo(); OutputHi, I'm picaso from seventh grade

How to convert JavaScript objects to primitive data types manually?

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

653 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

HTML DOM Meter min Property

AmitDiwan
Updated on 01-Aug-2019 06:36:25

141 Views

The Meter low property returns/sets a number corresponding to the min attribute of a element. Use this with high, max and low attributes for better results.SyntaxFollowing is the syntax −Returning value of the min propertymeterElementObject.minValue of the min property setmeterElementObject.min = numberExampleLet us see an example for Meter min property − Live Demo Meter min    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {       border-radius: 10px; ... Read More

Advertisements