How to console log the name of a variable/function?

后端 未结 6 1459
梦谈多话
梦谈多话 2020-12-09 12:58

I want to do this: log(variableOrFunction)

And be able to produce this: variableOrFunction: actualValue.

I tried this:



        
6条回答
  •  佛祖请我去吃肉
    2020-12-09 13:36

    The "value" is of type Object. Use JSON.stingify to see in details,

    export const log = (value) => {
      console.log('' + value + ':', JSON.stringify(value))
      console.log(JSON.stringify(value))
    }
    

提交回复
热议问题