How to store input value in javascript local storage in the form of array? [duplicate]
You should use concat
in this context to achieve your goal.
var foo = ["Hello"].concat(" word");
console.log(foo)
That is because you are storing the value that push returns on the variable foo
:
The push() method adds one or more elements to the end of an array and returns the new length of the array.
You can do it this way:
var arr = ["hello"];
arr.push(" word");
console.log(arr);