remove element from global array
Dec 02 2016 | 12:33 pm
Sorry for the pretty noob question, i am trying to build in JS a kind of "intelligent urn". I am stuck in a problem about arrays and global variables.
If i create an array inside a function it seems to work fine:
function removeElementInArray() {
var localArray = [2,3,4,6];
var splicing = localArray.splice(0, 1);
post (localArray[0]);
post();
}
this gives 3 as desired result.
I want of course to make the preceding function generic and If i create a global array and fill it with arguments of a max message:
var internalUrn = new Array();
function fillUrn(){
internalUrn = arguments;
}
and I try to apply the same operation:
function removeElementInArray2() {
var splicing = globaUrn.splice(0, 1);
post (globalUrn[0]);
post();
}
I get an error message:
Javascript TypeError: globalUrn.splice is not a function, line xxx
Seems it must be something simple but i cannot get it. Thanks for help....