[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ru/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.

In this article

JavaScript 64- IEEE 754 (.. , -(253 -1) 253 -1). . , : +, -, NaN (-). JavaScript JavaScript.

: , , .

js
1234567890;
42;

//        :

0888; // 888   
0777; //       (511  )

, (0) , 8, .

0 "B" (0b or 0B). 0b 0 1, SyntaxError : "Missing binary digits after 0b".

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

. 0 0 7, .

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

0 "X" (0x or 0X). 0x (0123456789ABCDEF), SyntaxError : "Identifier starts immediately after numeric literal".

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

Number

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.MAX_VALUE
Number.MIN_VALUE
Number.NaN " " ("not a number")
Number.NEGATIVE_INFINITY " ";
Number.POSITIVE_INFINITY " ";
Number.EPSILON , , Number.
Number.MIN_SAFE_INTEGER , JavaScript.
Number.MAX_SAFE_INTEGER , JavaScript.
Number.parseFloat() , , . parseFloat().
Number.parseInt() , , . parseInt().
Number.isFinite() , , , .
Number.isInteger() , , , .
Number.isNaN() , , , NaN ( ). , isNaN().
Number.isSafeInteger() , ., , .

Number , . , Number.prototype.

toExponential() , .
toFixed() , .
toPrecision() , .

Math

Math . , Math PI "" (3.141...),

js
Math.PI;

, Math. , , . , ,

js
Math.sin(1.56);

, 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() , ,
clz32(), imul() 32- . - 32- .

, Math. Math .

Date

JavaScript . , Date . Date , , .

JavaScript Java. , , 00:00:00 1 1970 .

, Data, -100 000 000 100 000 000 , 1 1970 .

Date :

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

dateObjectName , Date; , , .

Date , new, .

parameters , :

  • : . : today = new Date();.
  • , : " , ::". : 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);.

new Date().toLocaleString('ru',
  {
    day: 'numeric',
    month: 'long',
    year: 'numeric'
  });
//    : '10  2019 .'

toLocalString

Date

Date :

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

"get" "set", , , , , , . getDay, , setDay , - . :

  • : 0 59
  • : 0 23
  • : 0 () 6 ()
  • : 1 31
  • : 0 () 11 ()
  • : 1900 .

, , :

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

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

getTime setTime . getTime , 00:00:00 1 , 1970 .

, :

js
var today = new Date(); //   
var endYear = new Date(1995, 11, 31, 23, 59, 59, 999); //       
endYear.setFullYear(today.getFullYear()); //   
var msPerDay = 24 * 60 * 60 * 1000; //     
var daysLeft = (endYear.getTime() - today.getTime()) / msPerDay;
var daysLeft = Math.round(daysLeft); //   ,    

Date today, . , Date , endYear, , . , , today endYear, getTime , .

parse Date . , parse setTime IPOdate:

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

JSClock(), :

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 Date, time; , time . getHours, getMinutes getSeconds, hour, minute second.

time. temp, ; hour 12, (hour - 12), hour. , hour 0, "12".

temp. 10, , , . temp .

, "P.M." temp hour 12, , "A.M.".


Web Proxy Viewer  |  New URL  |  Original Page