declare a function's name without creating a variable

const x = {};
x.y = function y() {
  console.log("hello");
  y();
};
x.y();

as written, calling x.y() will infinitely recurse. this is particularly cumbersome if there is a y in the outer scope as it is now unreachable:

const x = {};
x.y = function y() {
  console.log("hello");
  y();
};
function y() {
  console.log("world");
}
x.y();

the only way to avoid it is like so:

x.y = function () {
  console.log("hello");
  y();
};
Object.defineProperty(x.y, "name", { value: "y" });

curious on other's thoughts on how they handle this, or run into it often.

I haven't found myself in the situation where the function name shadows an outer variable very often, but if I did I would probably create an outer alias to that variable:

const x = {};
const outerY = y;
x.y = function y() {
  console.log("hello");
  outerY();
};
x.y();