import React from "react";
import "./styles.css";
const App = () => {
return (
<div className="App">
<h1>{test.foo}</h1>
</div>
);
};
const test = {
foo: "foo"
};
export default App;
this code is from codesandbox : https://codesandbox.io/s/declaring-variable-test-oixgo
this code run without any issue, I thought in javascript, const and let are not hoisted,
so It should be declared and initialized first before It is used (I thought the order of executing code is important)
But In this case, Although test object is behind its usage, This code works without any error.
What has happened to this code?