Babel and the latest JavaScript syntax

We've been building up this application to act as our base and in the process we've introduced a lot of syntax that may not be the same JavaScript that you're used to writing! For example, we've written a few functions with this sort of syntax:

const foo = () => {
doSomething();
doSomethingElse();
}

The syntax here is not particularly tricky and you can probably figure out what's going on, but maybe you don't fully understand how all of that ends up as a function when all is said and done. You may be more used to writing functions in a similar pattern to the following:

var foo = function() {
doSomething();
doSomethingElse();
}

Or maybe something more like a function declaration without the variable, such as the following function:

function foo() {
doSomething();
doSomethingElse();
}

The reality is that as JavaScript progresses, there are new and more efficient methods of writing a large variety of different language constructs. Some offer helpful shortcuts, or maybe they provide a nice quality-of-life improvement for developers. Since Create React App runs on Node.js, we get some syntax improvements here and there, but generally speaking, Node integrates those new features and syntax into its standard library at a much slower pace.

Over the course of this chapter, we'll dive deeper into how to write, incorporate, and, most importantly, understand modern JavaScript code in our Create React App projects. We'll take a look at what features are currently supported in Create React App and learn how to take full advantage of each and every one of them!

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

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