0

I read some tutorial about Rang and Selection and start read this example:

<p id="p">Example: <i>italic</i> and <b>bold</b></p>

<script>
  let range = new Range();

  range.setStart(p, 0); // <------------------------- Here variable 'p' is used without declaration and is equal to an id of paragraph
  range.setEnd(p, 2);

  // toString of a range returns its content as text (without tags)
  alert(range); // Example: italic

  // apply this range for document selection (explained later)
  document.getSelection().addRange(range);
</script>

In this code variable 'p' is used without declaration and is equal to an id of paragraph.

Why is that and where can I read docs about this? Is this a new standard in javascript?

webprogrammer
  • 2,393
  • 3
  • 21
  • 27

0 Answers0