This chapter covers
- Using the JavaScript types
- Coercing JavaScript types
- Defining and using JavaScript functions and arrays
- Creating and implementing JavaScript objects
- Understanding the this keyword
Effective TypeScript development requires an understanding of how JavaScript deals with data types. This can be a disappointment to developers who adopt TypeScript because they found JavaScript confusing, but understanding JavaScript makes understanding TypeScript easier and provides valuable insights into what TypeScript offers and how its features work. In this chapter, I introduce the basic JavaScript type features, continuing with more advanced features in chapter 4.
3.1 Preparing for this chapter
To prepare for this chapter, create a folder called primer in a convenient location. Open a command prompt, navigate to the primer folder, and run the command shown in listing 3.1.
Tip
You can download the example project for this chapter—and for all the other chapters in this book—from https://github.com/manningbooks/essential-typescript-5.
Listing 3.1 Preparing the project folder
npm init --yes
To install a package that will automatically execute the JavaScript file when its contents change, run the command shown in listing 3.2 in the primer folder.
Listing 3.2 Installing a package
npm install nodemon@2.0.20