undoing parenting of object's transform

I made the transform of objectB the parent of objectA, to enable object A move along with objectB. As shown below

objectA.transform.parent = objectB.transform

Now, there is need to reverse the process, so that objectA can move on its own.

Regards

objectA.transform.parent = null

objectB.transform.DetachChildren();