This is called self-awareness. Other animals can do it too.