我需要将新变量添加到存储在 cookie 中的数组中。我怎么能这样做?
var arr = $.cookie("arr",[1, 2, 3, 4, 5, 6, 7, 8, 9]);
// this is an array of diferent numbers
function pri() { // this function create a number that is not in the array
var n = Math.floor((Math.random() * 15));
var tex;
while ((tex = $.inArray(n, arr)) != -1) {
n = Math.floor((Math.random() * 15));
}
return n;} //i need for whatever "n" is to be added to my array cookie