使用代码,我目前已经编写了(下面),我一直得到这个响应--“预期{}有一个属性'push'”和'pop‘的相同错误。我认为我添加的方法不正确。val to the end of the array// the goal of thisarray[array.length] = val;
return arr
我知道,当您使用push()或pop()函数时,它们分别在数组的末尾添加或删除某些内容。但是,我已经看到它们单独使用,而不是附加到数组上。有人能解释一下这做了什么,为什么会起作用吗?例如,与其声明数组并在其上使用push或pop,不如:array.push("something");//code up here//code in here/