Intro to JSX
Hello World

Take a look at the following line of code:

const h1 = <h1>Hello world</h1>;

What kind of weird hybrid code is that? Is it JavaScript? HTML? Or something else?

It seems like it must be JavaScript, since it starts with const and ends with ;. If you tried to run that in an HTML file, it wouldn’t work.

However, the code also contains <h1>Hello world</h1>, which looks exactly like HTML. That part wouldn’t work if you tried to run it in a JavaScript file.

What’s going on?



Copy the following line into app.js:

const h1 = <h1>Hello world</h1>;

Click Run when you’re finished.

Folder Icon

Take this course for free

Already have an account?