how should i display value of a function when it is defined as the key value of a key inside an object in JS?

Viewed 31

I was wondering how I can see the value of the function lome(),when i execute the code it shows [function:lome] but i want it to print lome.

    const h = {
  name: "conor",
  age: function lome() {
    console.log("hi");
  },
};
console.log(h);
1 Answers

Get the name of the function like that

const h = {
name: "conor",
age: function lome(){
    console.log('hi')
}
};

console.log(h.age.name)

Related