Maybe you can think about removing the attribute to a function. I mean something like this:
var obj = {
key1: "it ",
key2: function() {
return this.key1 + " works!";
}
};
alert(obj.key2());
More Related Contents:
- Most efficient method to groupby on an array of objects
- Add a property to a JavaScript object using a variable as the name?
- Convert Array to Object
- Convert JS object to JSON string
- What is the difference between ( for… in ) and ( for… of ) statements?
- What does [object Object] mean?
- Converting an object to a string
- Sorting a JavaScript object by property name
- How can I access and process nested objects, arrays or JSON?
- Filter array of objects with another array of objects
- Check if object value exists within a Javascript array of objects and if not add a new object to array
- How to set a Javascript object values dynamically?
- How to copy JavaScript object to new variable NOT by reference? [duplicate]
- Access object properties within object [duplicate]
- Render Object properties in React
- How to access nested JSON data
- JS: Does Object.assign() create deep copy or shallow copy
- how to iterate over inner objects / property in an object
- What’s the difference between “{}” and “[]” while declaring a JavaScript array?
- How to change HTML Object element data attribute value in javascript
- How to check the depth of an object?
- When should I automatically create an object even if `new` is forgotten?
- Using JavaScript what’s the quickest way to recursively remove properties and values from an object?
- Array.includes() to find object in array
- Javascript deep copying object [duplicate]
- Javascript – deepEqual Comparison
- Lodash create collection from duplicate object keys
- Setting one object equal to another object with the assignment operator in Javascript
- How to get all keys with values from nested objects
- What’s wrong with adding properties to DOM Element objects?