JavaScript Number Object

Source: Internet
Author: User
Tags object numeric numeric value return string tostring wrapper

JavaScript Number Object
---------Number object is the wrapper object for the original numeric value.
Create a Number Object
var num = new number (10);
var num = number (10); ---parentheses are the values of the number object that you want to create or the value that is converted to numbers.
return value:
1. Returns a newly created number object when number () and operator new are used together as constructors
2, directly using number () as a function to call, it will convert its own parameters to the numeric value of an element, and return it (if the conversion fails, then return nan)

/* Below a simple example * *
Number (NULL)//0
Number (true)//1
Number (false)//0
Number (' 1 ')//1
Number (' a ')//nan
Number (undefined)//nan

Number Object Description
In JavaScript, a number is a basic type of data. JavaScript also supports the number object, which is the wrapper object for the original numeric value. When necessary, JavaScript automatically converts between raw data and objects.
Number Object method
ToString---Converts a number to a string, using the specified cardinality

/* Converts a Number object to a string and returns the result * *
Numberobject.tostring (Radix)
-----Radix Optional Parameters. A rule that represents the cardinality of a number, making an integer between 2~36. The default is 10.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.