Skip to content

When you chain a property, do you call it?

This question concerns semantics of “property” and “method.” I understand that in JavaScript, a variable in an object is a property and a function in an object is a method.

In a Node.js application, I’m passing process.mainModule.filename as an argument to path.dirname(). mainModule is a property of the Process object (as I found in the Node docs). Is it correct to say I’m “calling” mainModule? Is it a method and a property in this case, or maybe a property that holds a method? (Also wondering the same for filename.)

Answer

It seems that mainModule is a property of process and it itself is an object with its own properties. One of them is filename.
So it won’t be “calling” but rather accessing one of its properties

Hope it helped