Skip to content
Advertisement

Tag: reflection

Reflect API and Serialization via JSON.stringify

The following JavaScript code does something I didn’t expect. Why is the serialized output from JSON.stringify missing the new bar property? Answer because this property is not enumerable. By default, properties added using Object.defineProperty() are not writable, not enumerable, and not configurable. see documentation : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty#description so you must do: This is similar for the length property upon arrays:

get name of input variable (like Function.name)

I have a Function in which I want to retrieve the name of the variable that was used to call the function. How can I do that? If variable was a Function, I could use variable.name. I am aware of this, but it will only return “variable”, not the name of the variable that was put into the function. As

Advertisement