从其他脚本调用函数时,我的代码出现了一些问题。 当我通过变量发送数据时添加1.是否有从最后2位数中获取值并从中删除1然后再将它们合并到主int中?
我在调用函数的地方:(test.js):
cards.getcards(76561198089544929, function(err, res, body){});
使用fucntion(index.js)编写脚本:
exports.getcards = function(steamid, callback){
console.log(steamid);
}
输出:76561198089544930
FIX
var steamid = 76561198089544930; //This is what I got from the function.
var toText = steamid.toString(); //convert to string
var lastChar = toText.slice(-2); //gets last character
var baseChars = toText.slice(0, -2);
var lastDigit = +(lastChar); //convert last character to number
var newlast = lastDigit - 1;
var steamid = baseChars+newlast;
alert(steamid);

答案 0 :(得分:1)
这个数字太大,无法容纳在javascript Number对象中。你有三个选择。要么使用字符串来存储数字,要么使用库来获得任意精确的数字,或者只是将数字设置得更小。