Other than the syntax errors (Use of the "[" and "]" in the wrong places) your code is perfect.
Here is the fixed one:
_this addWeaponCargoGlobal ["ej_m107",5];
_this addMagazineCargoGlobal ["Barret_mag",90];
As for the guide, you can always check things about a scripting command (info, usage, example code) in the wiki here
Ctrl + F will be one of your most valuable comrades!
Also, specifically for loadout editing; you can check LEA
. You can easily use it and learn from the code it generates too.