I wanna make the following piece of JS code, but, instead of 3 different variables, I want to group them in an object for easy future reference in the script.
const container = document.querySelector('.container');
const container_height = parseInt(window.getComputedStyle(container).getPropertyValue('height'));
const container_width = parseInt(window.getComputedStyle(container).getPropertyValue('width'));
In my understanding of objects as a group of variables I produced the following:
const container = {
elm : document.querySelector('.container'),
height : parseInt(window.getComputedStyle(this.elm).getPropertyValue('height')),
width : parseInt(window.getComputedStyle(this.elm).getPropertyValue('width'))
}
Isn't 'this' how you should go about referring to other variables within the object?
Edit: Terminal Error: Uncaught ReferenceError: elm is not defined.