A
A
Alexey2020-05-05 22:41:10
JavaScript
Alexey, 2020-05-05 22:41:10

Why is an array of numbers converted this way?

Why is the line let numbers = Number(arr.join('')); this is how it converts string to numbers, at the end it turns out ..000, although logically it should go ..77. I don’t understand this pattern, and the conversion works this way only with long arrays.

let array = [9, 2, 2, 3, 3, 7, 2, 0, 3, 6, 8, 5, 4, 7, 7, 5 , 6,7,7];
  let string = arr.join(''); //  "9223372036854775677"
  let numbers = Number(arr.join('')); // 9223372036854776000

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-05-05
@alekseyy__9090

MAX_SAFE_INTEGER

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question