This is not a recommended style since it allocates memory for the output.
The idea of g! is that it should modify the object that G refers to in-place. What you are doing here is simply rebinding the local G name to the array output by myfungradients(x), but outside the function, the passed object was not modified. See this for more details Values vs. Bindings: The Map is Not the Territory · John Myles White. When you modify the object that G binds to in-place, you are not allocating additional memory so that’s efficient.
I am actually surprised any of them works at all!
See these 2 examples: