![]() ![]() For example, we might talk about a Person object’s name (a String), age (a Number), and Halloween haul (an array of candy). These are known as attributes, fields or instance variables (variables that belong to a particular instance, or example, of the class). The data (variables) that describe the thing. In particular, classes encapsulate two things: So rather than needing to think about the program purely in terms of Numbers, Strings, and Arrays, we can think about it in terms of Dogs, Cats or Persons. The whole point of using classes in programming-whether Java or JavaScript-is to perform abstraction: we want to be able to encapsulate (“group”) together parts of our code so we can talk about it at a higher level. ![]() ![]() The next chapter discusses how to perform this transpiling with React (spoiler: it’s automatically performed by provided build tools), but it is also possible to install and utilize the Babel compiler yourself. The easiest way to do this is with the Babel compiler, which will “ transpile” JavaScript code from one version to another. Instead, you would need to covert that code into equivalent ES5 (or earlier) code, which can be understood. However, the JavaScript interpreter in older browsers (and IE) won’t be ale to recognize the new syntax introduced in this version. This chapter introduces some of the most notable and useful features introduced in ES6 and later versions of JavaScript-particularly those that will be utilized by the React framework (discussed in the following chapters).ĮS6 is mostly supported by modern browsers, with the notable exception of Internet Explorer. In 2015, a new version of the language was released-officially called “ECMAScript 2015”, most developers refer to it by the working name “ES6” (e.g., version 6 of the language).
0 Comments
Leave a Reply. |