Id in javascript

What is the meaning of output.id? What does it do? Please explain.

Can we get some context?

To me it looks like a property called “id” on an object called “output”.

1 Like

Hi @kevinSmith
const output = document.querySelector(’.output’);
output.textContent = “Hello World”;
output.classList.add(“red”);
output.id = “tester”;
output.style.backgroundColor = “red”;
console.log(document.URL);
output.textContent = document.URL;

So, in this context, output is an HTML element. So, output.id = “tester”; is giving that HTML element an id.

1 Like

Thank you @kevinSmith.
Understood.
Appreciate your response.