Hi everyone! My name is Adam and I was wondering how to use the .push function in JavaScript in everyday code?
If you have an array, and you want to add a value to it, you use push
.
const arr = [];
const val = 42;
console.log(arr); // []
arr.push(val);
console.log(arr); // [42]
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.