[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Guide/Numbers_and_strings [Back]  [Original]

- JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

JavaScript , . 10, 2, 16 Math .

In this article

JavaScript double-precision 64-bit binary format IEEE 754 (, 2^1022 2^+1023 10^308 to 10^+308 53bits ) . 2^53 - 1 .

, : +Infinity, -Infinity, and NaN ( ) .

JavaScript BigInt, . BigInt . , BigInt Number Math BigInt .

JavaScript JavaScript data types and structures .

: 10, 2, 8, 16

10

js
1234567890;
42;

//  0   :

0888; // 10 888 .
0777; // non-strict mode 10 511 .

10 (0) . 0 8 , 8 .

2

2 0 "B"(0B 0b) . 0b 0 1 SyntaxError . "0b 2 "("Missing binary digits after 0b").

js
var FLT_SIGNBIT = 0b10000000000000000000000000000000; // 2147483648
var FLT_EXPONENT = 0b01111111100000000000000000000000; // 2139095040
var FLT_MANTISSA = 0b00000000011111111111111111111111; // 8388607

8

8 0 . 0 0 7 , 10 .

js
var n = 0755; // 493
var m = 0644; // 420

ECMAScript 5 Strict 8 . 8 ECMAScript 5 , 0644 === 420 "\ 045"=== "%" 8 . ECMAScript 2015 0o 8 ( :

javascript
var a = 0o10; // ES2015: 8

16

16 0 "X"(0x 0X) . 0X (0123456789ABCDEF) , SyntaxError : " ".

js
0xfffffffffffffffff; // 295147905179352830000
0x123456789abcdef; // 81985529216486900
0xa; // 10

1E3   // 1000
2e6   // 2000000
0.1e2 // 10

Number

Number , not-a-number, . :

js
var biggestNum = Number.MAX_VALUE;
var smallestNum = Number.MIN_VALUE;
var infiniteNum = Number.POSITIVE_INFINITY;
var negInfiniteNum = Number.NEGATIVE_INFINITY;
var notANum = Number.NaN;

Number , Number .

Number .

Number.MAX_VALUE (1.7976931348623157e+308)
Number.MIN_VALUE (5e-324)
Number.NaN " "
Number.NEGATIVE_INFINITY ; .
Number.POSITIVE_INFINITY ; .
Number.EPSILON Number.(2.220446049250313e-16)
Number.MIN_SAFE_INTEGER JavaScript .(2^53 + 1, or 9007199254740991)
Number.MAX_SAFE_INTEGER JavaScript .(+2^53 1, or +9007199254740991)
Number
Number.parseFloat()

. parseFloat() .

Number.parseInt() , . parseInt() .
Number.isFinite() .
Number.isInteger() .
Number.isNaN() Not-a-Number . (isNaN) .
Number.isSafeInteger() .

Number Number . Number.prototype .

Description
toExponential() .
toFixed() .
toPrecision() .

Math

Math . , Math PI pi (3.141 ...) . .

js
Math.PI;

Math . , , . sine .

js
Math.sin(1.56);

Math .

Math .

Math
abs()
sin(), cos(), tan() ;
asin(), acos(), atan(), atan2() ;
sinh(), cosh(), tanh() ; .
asinh(), acosh(), atanh() ; .

pow(), exp(), expm1(), log10(), log1p(), log2()

.
floor(), ceil() / / .
min(), max() () .
random() 0 1 .
round(), fround(), trunc(), .
sqrt(), cbrt(), hypot() , , .
sign() 0 .
clz32(),
imul()
32 .
C-like 32 .

Math . Math .

Date

JavaScript . , Date . Date , . (properties) .

JavaScript . 1970 1 1 00:00:00 . 1970 1 1 00:00:00 .

Date UTC 1970 1 1 -100,000,000 100,000,000 .

Date :

js
var dateObjectName = new Date([parameters]);

dateObjectName Date . .

new Date .

parameters .

  • : . , today = new Date();.
  • : "Month day, year hours:minutes:seconds." , var Xmas95 = new Date("December 25, 1995 13:30:00"). , , , 0 .
  • , , . , var Xmas95 = new Date(1995, 11, 25).
  • , , , , , .. , var Xmas95 = new Date(1995, 11, 25, 9, 30, 0);.

Data

Date :

  • "set" , .
  • "get" , .
  • "to" , .
  • Date parse UTC .

"get" "set" , ,, , , . () , getDay , setDay . .

  • : 0 to 59
  • : 0 to 23
  • : 0 (Sunday) to 6 (Saturday)
  • : 1 to 31 (day of the month)
  • : 0 (January) to 11 (December)
  • : years since 1900

, :

js
var Xmas95 = new Date("December 25, 1995");

Xmas95.getMonth() 11 , Xmas95.getFullYear() 1995 .

getTime setTime . getTime Date 1970 1 1 00:00 .

, :

js
var today = new Date();
var endYear = new Date(1995, 11, 31, 23, 59, 59, 999); // Set day and month
endYear.setFullYear(today.getFullYear()); // Set year to this year
var msPerDay = 24 * 60 * 60 * 1000; // Number of milliseconds per day
var daysLeft = (endYear.getTime() - today.getTime()) / msPerDay;
var daysLeft = Math.round(daysLeft); //returns days left in the year

today Date . endYear Date . getTime today endYear .

Parse Date . , IPOdate parse setTime ;

js
var IPOdate = new Date();
IPOdate.setTime(Date.parse("Aug 9, 1995"));

JSClock() digital .

js
function JSClock() {
  var time = new Date();
  var hour = time.getHours();
  var minute = time.getMinutes();
  var second = time.getSeconds();
  var temp = "" + (hour > 12 ? hour - 12 : hour);
  if (hour == 0) temp = "12";
  temp += (minute < 10 ? ":0" : ":") + minute;
  temp += (second < 10 ? ":0" : ":") + second;
  temp += hour >= 12 ? " P.M." : " A.M.";
  return temp;
}

JSClock time Date . . getHours, getMinutes getSeconds , hour, minute, second .

. temp . hour 12 (hour - 12), 0 12 12.

temp minute . (minute) 10 0 . . temp .

"P.M." . (hour) 12 (temp); "A.M." temp .


Web Proxy Viewer  |  New URL  |  Original Page