Hello I am new to javascript and I came across this code which I don't quite get and the code is
let element = document.querySelector(".some-class")
element.x = "hello world"
console.log(element.x)
And this code logs hello world to the console.
So my question is that are the DOM elements treated as objects(because in objects we use the same syntax like obj.color for example.)
And what does that x mean in general?
With element.x you added a attribute to your element object, with just this code, document.querySelector(".some-class") is useless, it would do the same if you just had declared an empty variable element.
However, you can edit the element in the HTML with this syntax, for example
let element = document.querySelector(".some-class");
element.innerHTML = "bb";