Why can I log an object value before declaration?

I just notice that the code below works even before I declare anything using var, let or const. I read an explanation that I’m creating anything on the global/window object (in non-strict mode), but I’m not doing any variable declaration/creation here (instead just throwing anything out of nowhere).

So, anything = {} is enough for JS to understand that I’m declaring (and initializing) anything? How does this really work?

anything = { 1: "anything" }
console.log(anything) // {1: "anything"}