In order to delete an entity in Drupal we can use entity storage to load an entity and then call "delete" method for it.
// Delete a node.
$node = \Drupal::entityTypeManager()->getStorage('node')->load(1);
if (!empty($node)) {
$node->delete();
}
Or we can load an entity using static method "load" and then remove it.
// Delete a node.
$node = Node::load(1);
if (!empty($node)) {
$node->delete();
}
Delete multiple nodes in one operation.
\Drupal::entityTypeManager()->getStorage('node')->delete([
$nid1 => $node1,
$nid2 => $node2,
]);