If I have a function:
function testDirectory(filePath) {
return __dirname === path.dirname(filePath);
}
Can I call this a pure function? By definition of pure function,
However, depending on where this function is defined, the result changes. So, in a way it is dependent on context ( location in this case.)
Yes, this function is pure since __dirname
is a constant. It does not matter at all how that constant did get its value (in this case, during the compilation of the module).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.