Trying to get my head around how to add and remove entity references.
I have node A which has an entity reference field to another content type.

I am programmatically creating A nodes and need to first remove existing references and then recreate them (more than one node can be referenced 'unlimited').
I've been reading documentation, but still none the wiser on how to do this