0
const paragraph = document.createElement('p');
console.log(paragraph.textContent);
console.log(paragraph)
paragraph.textContent = "I'm a brand new paragraph.";
console.log(paragraph);

Above code is giving below output enter image description here

we're logging paragraph element before assigning textContent then how can it have updated value although paragraph.textContent is empty string at that time.

I'm new to JS and learning DOM. Can someone explain what is this behavior?

Utsav Patel
  • 157
  • 2
  • 13

0 Answers0