Your variable myVar doesn't get defined until fetch receives the results, but fetch is an asychronous function, so console.log runs before myVar is defined.
If you want to wait for the results of an asynchronous function before proceeding with execution, you need to use the await keyword:
let myVar = await fetch("myFile.json").then(res => res.json());
console.log(myVar);