Skip to content

Commit aafe39f

Browse files
timagixetshemsedinov
authored andcommitted
Cast BigInt to Number
1 parent 4d9db53 commit aafe39f

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

JavaScript/9-bigint.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,7 @@ console.log();
5151
const array1 = [-2, 7, 1n, 3, -2n, 8n, 5, -4n];
5252
console.log(array1);
5353
console.log(array1.sort());
54-
console.log(array1.sort((a, b) => {
55-
const biA = BigInt(a);
56-
const biB = BigInt(b);
57-
if (biA < biB) return -1;
58-
if (biA > biB) return 1;
59-
return 0;
60-
}));
54+
console.log(array1.sort((a, b) => Number(BigInt(a) - BigInt(b))));
6155
console.log();
6256

6357
// https://github.com/tc39/proposal-bigint

0 commit comments

Comments
 (0)