If we hold one end of a slinky and leave other end free, the earth's gravity applies force on the slinky and it expands. If we do the same on the moon with the same slinky, will the acquired height of the slinky be different?
For a typical slinky (wiki) and comparing the gravity of earth and moon, this will be the case as outlined by the other answers.
However, for a general spring (wiki) or weaker gravity fields, the spring may be in a state where it is fully contracted and the weight of its own mass is insufficient to stretch it at all. In that regime, gravity does not play a role.