I have an object called headers. Inside which I want to add certain headers with some random value like: The config paramter is used to client which is used to send http requests. And the randomid is some id generated by a load balancer. So it will we different for every request. We dont want to create a new client
Tag: getter-setter
defining getters/setters in an object literal with a self-invoking function javascript
When defining an object literal its possible to use a self-invoking function so the function has access to private variables, But is it possible to do the same thing with a getter/setter in an object literal? Answer [edit 2022] A pretty old answer. More actual: you can create a factory function. In the snippet the factory creates an object with