Javascript Number Objects - Properties and Methods
Description
A number object holds primitive numeric values.
Can be created by number constructor, for example, new Number(value) or Number (value), where "value" is the numeric value of the Number object to be created, or value to be converted to a number.
Javascript Number Objects Property
Name | Description | Version |
---|---|---|
constructor | Specifies the function that creates an object's prototype. | Implemented in JavaScript 1.1 |
MAX_VALUE | Returns the maximum numeric value represented in JavaScript. | Implemented in JavaScript 1.1 |
MIN_VALUE | Returns the number closest to 0, not the negative number represented in JavaScript. | Implemented in JavaScript 1.1 |
NaN | Represents a value that is not a number | Implemented in JavaScript 1.1 |
NEGATIVE_INFINITY | A special numeric value represents negative infinity. | Implemented in JavaScript 1.1 |
POSITIVE_INFINITY | A special numeric value represents positive infinity. | Implemented in JavaScript 1.1 |
prototype | Allows the add of properties to a Number object. | Implemented in JavaScript 1.1 |
Javascript Number Objects Methods
Name | Description | Version |
---|---|---|
toSource | Use to get a string representation (source code) of the number object. | Implemented in JavaScript 1.3 |
toString | Use to get a string representation of the specified number object. | Implemented in JavaScript 1.1 |
valueOf | Returns the primitive value of a number object as a number data type. | Implemented in JavaScript 1.1 |
See also:
Test your Programming skills with w3resource's quiz.
JavaScript: Tips of the Day
How to insert an item into an array at a specific index (JavaScript)?
What you want is the splice function on the native array object.
arr.splice(index, 0, item); will insert item into arr at the specified index (deleting 0 items first, that is, it's just an insert). In this example we will create an array and add an element to it into index 2:
var arr = []; arr[0] = "Jani"; arr[1] = "Hege"; arr[2] = "Stale"; arr[3] = "Kai Jim"; arr[4] = "Borge"; console.log(arr.join()); arr.splice(2, 0, "Lene"); console.log(arr.join());
Ref: https://bit.ly/2BXbp04
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework