{"name":"pushBack","title":"pushBack","type":"command","url":"https://community.bistudio.com/wiki/pushBack","revid":377141,"updated":"2026-01-01T10:30:59Z","groups":["Arrays"],"status":"ok","games":{"arma3":"1.26"},"since":"arma3 1.26","arma3_since":"1.26","description":"Insert an element to the back of the given array. This command modifies the original array. (see also: pushBackUnique)","syntaxes":[{"syntax":"array pushBack element","params":[{"name":"array","type":"Array of Anything","type_expr":"Array<Anything>"},{"name":"element","type":"Anything","type_expr":"Anything"}],"returns":{"type":"Number","type_expr":"Number","description":"index of inserted element"},"form":"binary","left":{"text":"array"},"right":{"text":"element"}}],"examples":[{"code":["_arr = [1,2,3];\n_arr pushBack 4;\nhint str _arr; //[1,2,3,4]"]},{"code":["_arr = [1,[2,4],3];\n(_arr select 1) pushBack [5,6];\nhint str _arr //[1,[2,4,[5,6]],3]"]}],"see_also":["pushBackUnique","select","set","resize","reverse","count","find","in","forEach","deleteAt","deleteRange","append","sort","arrayIntersect","apply","BIS_fnc_arrayPushStack","BIS_fnc_arrayPush"],"notes":[{"user":"ffur2007slx2_5","date":"2014-08-01T21:15:00Z","text":"(A3 1.26) It is recommended to use pushBack instead of BIS_fnc_arrayPush.\n\n```sqf\n_array = [1,2,3];\n_array pushBack 4; //same as [_array, 4] call BIS_fnc_arrayPush;\n```"},{"user":"Skaronator","date":"2014-08-23T21:35:00Z","text":"It's highly recommended to use the new pushBack command, up to 43% faster than set and up to **11843%** faster a plus b!"},{"user":"DreadedEntity","date":"2014-11-26T18:25:00Z","text":"pushBack does not support nil while set and a plus b do. For example:\n\n```sqf\n_array = [];\nfor \"_i\" from 0 to 3 do\n{\n    _array pushBack nil;\n};\nhint str _array; //hint is []\n```"},{"user":"Killzone_Kid","date":"2015-05-21T10:52:00Z","text":"Array \"push\" implementation using pushBack, alternative to BIS_fnc_arrayPush\n\n```sqf\nKK_fnc_push = {\n    _this select 0 pushBack (_this select 1);\n    _this select 0\n};\n\n// Example\narr = [1,2,3];\n[arr, 4] call KK_fnc_push; //both arr and return of function are now [1,2,3,4]\n```"},{"user":"OOKexOo","date":"2016-10-05T02:19:00Z","text":"Note that pushBack does not create a new object.\nTherefore, if you edit an object that was pushed back to an array, it also affects the object in the array.\ne.g.\n\n```sqf\n_first_squence = [1,2,3];\n_second_squence = [5,4];\n\n_first_squence pushBack _second_squence;\nsystemChat str _first_squence // prints [1,2,3,[5,4]]]\n\nreverse _second_squence;\nsystemChat str _first_squence // prints [1,2,3,[4,5]]]\n```\n\nIf you pushBack an array for instance, you can just copy it to generate a new object.\ne.g.\n\n```sqf\n_first_squence pushBack +_second_squence;\n```"}]}