Moving a node or by adding extra tags to it will create a new version.
Deleting a node (with the editor) and creating a new node (again with the editor) will create a new id.
When you delete a way, all its nodes are deleted.

JOSM has a capability (via plugin ?) to replace one way with another. In that case it will try to reuse the node ids from the older way, as well as giving the new way the id of the old way.

@"When you delete a way, all its nodes are deleted.": depends on what the editor does. At least for JOSM, if I remember correctly, it only deletes the way's nodes too if the nodes themselves have no tags.