J.k. Rowling said this quote
“ He did not know or care whether they were wizards or Muggles, friends or foes; all he cared about was that a dark stain was spreading across Dobby's front, and that he had stretched out his thin arms to Harry with a look of supplication. Harry caught him and laid him sideways on the cool grass.Dobby, no, don't die, don't die -The elf's eyes found him, and his lips trembled with the effort to form words.Harry...Potter...And then with a little shudder the elf became quite still, and his eyes were nothing more than great glassy orbs, sprinkled with light from the stars they could not see. ”