When we have
document.getElementById("someid").textContent
is textContent
an instance of the method getElementById
, or a method of the object document
?
document.getElmentById("someid").textContent;
is "textContent" an instance of the method "getElementById()" , or a method of the object "document"
textContent
is neither of these. "instance of a method" is not a thing. And it clearly is not a method of document
because we didn't do document.textContent
.
Let's break this into smaller pieces:
document
This is variable that refers to an object.
document.getElmentById("someid")
This is a function call where we pass a string "someid"
as an argument and it returns a value.
document.getElmentById("someid").textContent;
This refers to the textContent
property of the object that was returned by the function call. The value referred to here could be a simple value, such as a string, or it could be a more complex object. Just from the code, we cannot tell. To find out specifics, we can google javascript getElementById
and find some documentation.
Another way to understand this better, try breaking the single line into multiple lines:
cosnt element = document.getElmentById("someid");
console.log(element);
console.log(element.textContent);