-1
我无法尝试使用JavaScript将对象添加到数组。 我已经搜索了其他问题,但我的问题更具体。将对象添加到具有命名字段的数组中
这是我的数组:
dataGameDentro = [{ Name : "EM1Aaa", Pontos : 7000 },{ Name : "EM1B", Pontos : 400 }];
我想补充
var currentPoint = $('#points-final').html().toString();
dataGameDentro.push({Name:"e5", Pontos : currentPoint});
或
dataGameDentro.splice(dataGameDentro.length, 0, {Name:"e5", Pontos : currentPoint});
,但它不工作。我的代码有什么问题?
$('#points-final')。html()里面有什么? – Eric
请更多代码,数组可能超出范围。你有错误吗? – WhiteHat
_it不工作是什么意思?发生了什么,你不期望发生,或什么不发生,你预计会发生?显示的代码看起来不错:您可以使用push()将对象添加到数组中。 – dsh