从 BigInt() 中删除附加的 'n'

Removing appended 'n' from BigInt()

我正在尝试使用 BigInt() 来计算大于 20 的数字的阶乘。

下面是我计算阶乘的函数:

function extraLongFactorials(n) {
// let result=BigInt(1);
// console.log(typeof(result));
let result=BigInt(1);
for(let i=n;i>1;i--){
result*=BigInt(i);
}
// console.log(typeof(result));
// console.log(result);
// BigInt.prototype.toJSON = function() { return this.toString()  }
// result=JSON.stringify(result)
console.log(result);

}

我得到了结果,但是最后 n 被附加了,所以结果类似于 15511210043330985984000000n,而我应该显示结果 15511210043330985984000000。 有没有办法去掉最后的n?

使用toString:

console.log(result.toString());
// or
console.log(String(result));
// or
console.log('' + result);