Exploring modern JavaScript with Babel

Over the course of this section, we're going to explore the different modern JavaScript tricks and techniques that Babel allows us to use as a major part of our code. We'll take a look at the different ways that we can implement all kinds of different code and patterns, exploring the differences between the JavaScript standard ways to do certain tricks and the shorthand syntax that Babel will allow us to use. The first, especially if you haven't written any modern JavaScript in a long time, is the addition of different variable declarations, such as const and let.

The let variable allows us to declare a variable with very specific scoping rules. While var is scoped to the nearest function block and gets used as a result of that, let is instead scoped to the nearest block in general, and can't be used before it's declared. You also can't redeclare variables with the same name with let.

The const variable allows us to declare a constant with the same scoping rules as let, overall. The best practice is to use both of these far more than using var. In fact, I personally never use var if I'm working with code that I know supports const and let instead.

Now, let's move on to the first more complex thing we've run into as part of our application code: JSX!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.220.120