Note: If you use array_push() to add one element to the array, it's better to use $array[] = because in that way there is no overhead of calling a function.
{"1_8i1q0":{"state":{"baobab":{"parentNode":{"context":{"genInfo":{"prefix":"1_8i1qw01-0-1"},"ui":"desktop","service":"web","reqid":"1721285591520677-7375371676868839723-balancer-l7leveler-kubr-yp-sas-92-BAL","fast":{"name":"branding"}}}}},"type":"branding"},"1_8i1q1":{"state":{"visibleItems":[{"marker":"bullet","level":1,"content":[{"type":"text","text":"The array push method appends an element (or elements) to the end of an Array."}]},{"marker":"bullet","level":1,"content":[{"type":"text","text":"It returns the new length of the array."}]},{"marker":"bullet","level":1,"content":[{"type":"text","text":"You can append a single item or multiple items or merge two or more arrays."}]},{"collapsed":1,"is_list":1,"content":[{"marker":"bullet","level":1,"content":[{"type":"text","text":"The push method alters the original array. It changes its length and content."}]}]}],"path":{"items":[{"text":"tektutorialshub.com"}],"favicon":{"index":0,"pageNumber":0,"size":"m","entry":"1"}},"url":"https://www.tektutorialshub.com/javascript/array-push-method-in-javascript/","favicon":{"index":0,"pageNumber":0,"size":"m","entry":"1"},"headline":"Array Push Method in JavaScript - TekTutorialsHub","titleLines":1,"shouldWrapFold":false,"shouldOpenAllCollapsers":false,"disableReadMore":false,"hasA11yHeader":false,"siteSource":{"url":"https://www.tektutorialshub.com/javascript/array-push-method-in-javascript/","title":{"title":"Array Push Method in JavaScript - TekTutorialsHub","lines":1},"subtitle":{"path":{"items":[{"text":"tektutorialshub.com"}],"favicon":{"index":0,"pageNumber":0,"size":"m","entry":"1"}}}},"footer":{"report":{"featureInfo":{"type":"Факт","subtype":"Расширенный факт","fact":{"type":"Расширенный факт","isText":true}},"feature":"","checkBoxLabels":[]},"addonBefore":"Kaynaktan alınan bilgiyle göre oluşturuldu"},"baobab":{"parentNode":{"context":{"genInfo":{"prefix":"1_8i1qw02-0-1"},"ui":"desktop","service":"web","reqid":"1721285591520677-7375371676868839723-balancer-l7leveler-kubr-yp-sas-92-BAL","fast":{"name":"rich_fact"}}}}},"type":"rich_fact"}}
Definition and Usage. The array_push() function inserts one or more elements to the end of an array. Tip: You can add one value, or as many as you like.
Unlike most languages where array is a reference to the multiple variables, in JavaScript array is a single variable that stores multiple elements. ... array.push().
So the arraypush method will add a new element to the end of the array to which it is called off of, and it will also return the length of the new array.
Note that the array_push() function modifies the input array. The array_push() has the same effect as the following statement repeated for each new value
array_push treats array as a stack, and pushes the passed variables onto the end of array. The length of array increases by the number of variables pushed.