问题
I am following along with this Udemy course on "Advanced JavaScript", currently reviewing Scopes and watching the video " 9. What is an IIFE and why might you use it?".
The instructor is using Chrome DevTools to show JS examples, and created the following three snippets - main.js, other.js, index.html
The instructor is trying to show that running main.js will print out:
main: Object{hello: "main"}
other: Object{hello: "other"}
For some reason my index.html file that I'm creating in Chrome DevTools has an error (x) on line 1. I have it saved as "index.html" and following along exactly, so not sure why the doc isn't being recognized as html. I tried refreshing and saving but nothing.
my index.html with error
Semi-related, I tried to run main.js with other.js and index.html written out and saved, but main.js only prints out < main >{hello: "main"} >, not the other.js object as well. I assume this has to be due to the index.html file not working properly.
Anybody know what I'm doing wrong?
来源:https://stackoverflow.com/questions/59121329/index-html-throwing-an-error-in-chrome-devtools