{"name":"pushBackUnique","operator":null,"title":"pushBackUnique","type":"command","url":"https://community.bistudio.com/wiki/pushBackUnique","revid":377140,"updated":"2026-01-01T10:30:41Z","groups":["Arrays"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"1.56"}],"since":{"game":"arma3","name":"Arma 3","version":"1.56"},"arma3_since":"1.56","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Adds element to the back of the given array but only if it is unique to the array. The index of the added element is returned upon success, otherwise -1. This command modifies the original array.\n\n> [!NOTE]\n> Adding string elements is **case sensitive**.","syntaxes":[{"syntax":"array pushBackUnique element","since":null,"effect":null,"exec":null,"params":[{"name":"array","type":"Array of Anything","optional":false,"default":null,"description":null,"types":["Array","Anything"],"since":null,"text":"array: Array of Anything"},{"name":"element","type":"Anything","optional":false,"default":null,"description":null,"types":["Anything"],"since":null,"text":"element: Anything"}],"returns":{"type":"Number","types":["Number"],"description":"index of inserted element or -1","text":"Number - index of inserted element or -1"},"form":"binary","operator":null,"left":{"text":"array","types":["Array","Anything"]},"right":{"text":"element","types":["Anything"]}}],"examples":[{"text":"```sqf\n_arr = [1,2,3];\n_index = _arr pushBackUnique 3;\nhint str [_index, _arr]; // [-1,[1,2,3]]\n```","code":["_arr = [1,2,3];\n_index = _arr pushBackUnique 3;\nhint str [_index, _arr]; // [-1,[1,2,3]]"]},{"text":"```sqf\n_arr = [1,2,3];\n_index = _arr pushBackUnique 4;\nhint str [_index, _arr]; // [3,[1,2,3,4]]\n```","code":["_arr = [1,2,3];\n_index = _arr pushBackUnique 4;\nhint str [_index, _arr]; // [3,[1,2,3,4]]"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["pushBack","select","set","resize","reverse","count","find","in","forEach","deleteAt","deleteRange","append","sort","arrayIntersect","apply","BIS_fnc_arrayPushStack","BIS_fnc_arrayPush"],"notes":[],"categories":["Arma 3: New Scripting Commands","Arma 3: Scripting Commands","Command Group: Arrays","Introduced with Arma 3 version 1.56","Scripting Commands"]}