Yes, JavaScript gives you a direct method for this!
You can use unshift() to insert an element at the beginning:
theArray.unshift(response);
This modifies the original array and adds the element to index 0. Simple, readable, and native.
Yes, JavaScript gives you a direct method for this!
You can use unshift() to insert an element at the beginning:
theArray.unshift(response);
This modifies the original array and adds the element to index 0. Simple, readable, and native.