Alternatively, you can use a self starting function to give you a similar affect to what you are looking for:
var a = (function() {
var b = 10;
return {
b:b,
c:b*2
}
})();
console.log(a.c);
More Related Contents:
- “Uncaught SyntaxError: Unexpected token , ” when create my object javascript
- Detecting an undefined object property
- Weird behavior with objects & console.log [duplicate]
- How to get the difference between two arrays of objects in JavaScript
- How to get a key in a JavaScript object by its value?
- How to create an object property from a variable value in JavaScript? [duplicate]
- Why can I add named properties to an array as if it were an object?
- How to get the size of a JavaScript object?
- JavaScript: filter() for Objects
- Object property name as number
- Sum JavaScript object propertyA values with the same object propertyB in an array of objects
- String to object in JS
- How to get objects value if its name contains dots?
- How to get object length [duplicate]
- Merge keys array and values array into an object in JavaScript
- How to iterate (keys, values) in JavaScript? [duplicate]
- How to sum the values of a JavaScript object?
- Convert JavaScript array of 2 element arrays into object key value pairs
- JavaScript equivalent of jQuery’s extend method
- Count duplicates within an Array of Objects
- JavaScript, elegant way to check nested object properties for null/undefined [duplicate]
- What is the type of “keys” in JavaScript?
- Why does (“foo” === new String(“foo”)) evaluate to false in JavaScript?
- How do I reference the same Object’s properties during its creation? [duplicate]
- Find all values by specific key in a deep nested object
- Javascript oddness with array of objects and indexOf
- Filter nested array in object array by array of values
- how to use javascript Object.defineProperty
- Return an object key only if value is true
- How to merge duplicates in an array of objects and sum a specific property? [duplicate]