// free function
function test() {
return functionName(); // caller === test
}
// methods within object
const o = {
method1() {
return functionName(); // caller === method1
},
method2() {
return functionName(); // caller === method2
}
};
// test code
test(), // 'test'
o.method1(), // 'method1'
o.method2(), // 'method2'