Found 8862 Articles for Front End Technology

How to modify an array value of a JSON object in JavaScript?

Sai Teja Kotha
Updated on 07-Dec-2022 12:59:09

7K+ Views

In this article, we are going to discuss how to modify an array value of a JSON object in JavaScript. We try to update a new value or modify the existing value in an array. Modifying an array is just like modifying an object when that array is inside the object. The normal general principles of modifying will apply here. Syntax Following is the syntax of the for…in statement. for (var in obj) { //code } Example 1 In this example, we are trying to loop through an array using the for…in statement. This statement ... Read More

How to get the Width and Height of the screen in JavaScript?

Sai Teja Kotha
Updated on 07-Dec-2022 12:51:20

9K+ Views

In this article, we are going to discuss how to get the width and height of the screen in JavaScript. Javascript provides an window.screen object that contains information regarding the user's screen. The information includes height and width, and also many other features. To find the height and width of the screen you need to use the following read-only properties Screen.height − This property is used to get the height of the screen in pixels. Screen.width − This property is used to get the width of the screen in pixels. Syntax Following is the syntax of the height ... Read More

How to find whether a provided number is safe integer or not in JavaScript?

Aman Kumar
Updated on 06-Dec-2022 08:07:15

204 Views

Java script provides a Number.isSafeInteger() to check whether the given number is a safe integer or not. If the integer is safe then returns true otherwise it will return false.. JavaScript has some restrictions regarding the number, any number should be in an SCNF standardized computer network format. If a number breaches the rule, then it is not a safe integer. The reason behind that the number is that JavaScript uses double-precision floating-point format numbers as specified in IEEE 754 and can only safely represent integer b/w −(2^53-1) and (2^53-1) Example 1 In the following example, we check the ... Read More

How to compare dates in JavaScript?

Aman Kumar
Updated on 06-Dec-2022 08:02:13

3K+ Views

Dates can be compared easily in the JavaScript the dates can belong to any frame like past, present, or future. Past dates can be compared to the future and the future can be compared to the past and present. The date object will do what you want to construct one for each, then compare them using the ( >, today) { var date = "The date you provide is a future date"; } else { var ... Read More

What is the use of parsing dates in JavaScript?

Aman Kumar
Updated on 06-Dec-2022 07:59:41

103 Views

The date. parse() method parsing a string representation of a date, and returns the number of milliseconds. parse() parse a date string and returns the time difference between midnight 1, 1970 to provided date. The date. parse() method is used to know the exact number of milliseconds that have passed from midnight, January 1, 1970, till the date we provide. Syntax Following is the syntax of the parse() function − Date.parse(dateString) This method accepts only one parameter and holds the date as a string. It returns an integer value that represents the number of milliseconds between January 1, 1970, ... Read More

How to invoke a function with a function constructor in JavaScript?

Aman Kumar
Updated on 06-Dec-2022 07:53:41

1K+ Views

A function constructor invocation creates a new object. The new object inherits the properties and methods from the constructor. This keyword in the constructor does not have a value. This value will be a new object created when the function is invoked. Function construction creates functions that execute the global scope only. In JavaScript invoking a function with a function, the constructor is different from invoking a function as a method or invoking a function. Because it creates a new object that constructs properties and methods. Syntax Following is the snippet invoking a function with a function constructor. Here, we are ... Read More

What is the importance of '+' operator in type conversion in JavaScript?

Aman Kumar
Updated on 06-Dec-2022 07:48:50

150 Views

Java script is an autonomous type of language most of the time operation directly convert the value of their write type. But there are also cases in which we need to do explicit type conversion.While Java script provides many ways to convert data from one form to another. But there are two most common types of conversion. converting the value to a string. converting a value to a number. Implicit conversion There are various operators and functions in the JavaScript that automatically convert values to the right type like the alert() function in JavaScript accepts any value and ... Read More

How to remove the last digit of a number and execute the remaining digits in JavaScript?

vineeth.mariserla
Updated on 06-Dec-2022 07:44:55

4K+ Views

In this article we are going to discuss how to remove the last digit of a number and execute the remaining digits using JavaScript.A number firstly should be converted into the string after that you perform your operation like the length of the string − 1 after the removed the last element and execute the remaining part. Here type conversion is needed because we are changing the number to a string. Syntax Following is the syntax of the substring() method − str.substring(0, str.length - 1) This method accepts two parameters as an argument first is the string index from where you ... Read More

What is the relation between 'null' and '0' in JavaScript?

Aman Kumar
Updated on 06-Dec-2022 07:41:06

3K+ Views

It looks very odd to hear that because in mathematics if we have two numbers i.e a and b and if a is not less than b then the possible scenarios are either a is greater than or equal to b. But in the case of null and “0” null is not greater than "0" or equal to "0" but greater than or equal to "0". (null>=0) In JavaScript "0" is equal to false because "0" is a type of string when it is tested for equality the automatic type conversion of JavaScript will come into effect and convert the ... Read More

How to shallow copy the objects in JavaScript?

Aman Kumar
Updated on 06-Dec-2022 12:41:43

346 Views

In this article we are going to discuss how to perform shallow copy on JavaScript objects. If the source value is the reference to an object, then it will only copy the reference value into the target value. When the source properties are copied without reference and there exists a source property whose value is an object and is copied as a reference. A shallow copy constructs a new compound object and then (to the extent possible) inserts references into the objects found in the original. Using the _.extend() method Underscore.js are a library of JavaScript and has a method ... Read More

Advertisements