Basically JavaScript is:
- JavaScript will attempt to convert data types when they are combined with an operator.
- JavaScript functions can be defined with a literal syntax that declares parameters and a function body or using the fat arrow/lambda function syntax.
- JavaScript functions can accept a variable number of arguments, which can be captured using a rest parameter.
- JavaScript functions do not formally declare results and can return any result type.
- JavaScript arrays are variable-length and can accept values of any type.
- JavaScript objects are a collection of properties and values and can be defined using a literal syntax.
- JavaScript objects can be altered to add, change, or remove properties.
- JavaScript objects can be defined with methods, which are functions assigned to a property.
- The this keyword refers to different objects depending
on how functions are invoked.
JavaScript features for dealing with objects, sequences of values, collections, and the use of modules. These are all JavaScript features, but, as you will learn, understanding them helps put TypeScript into context and sets the foundation for effective TypeScript development. JavaScript objects have a prototype from which they inherit properties and methods.
- Objects can be created in a literal form or using a constructor function.
- JavaScript classes create a consistent template for creating objects.
- JavaScript classes support private fields, properties, and methods.
- Iterators and generators produce sequences of values.
- JavaScript objects and arrays can be used as simple collections, but you can also use a built-in map collection.
- Modules are used to structure a project, using either the ECMAScript or CommonJS module formats.
TypeScript compiler, which is responsible for transforming TypeScript code into pure JavaScript.
- TypeScript projects have a structure that keeps the TypeScript code written by the developer separate from the JavaScript code executed by the runtime.
- The TypeScript tools are added to a project using the standard JavaScript package manager, NPM, or one of its competitors.
- The TypeScript compiler processes the TypeScript files in the project and generates pure JavaScript files.
- The tsconfig.json file is used to configure the way the compiler generates JavaScript files.
- The TypeScript compiler can be used in watch mode, where TypeScript files are compiled when change is detected, but a third-party package, such as tsc-watch, is required to automatically execute the generated JavaScript files.
- The TypeScript compiler can generate code that conforms to different versions of the JavaScript language specification.
- The TypeScript compiler can generate code that uses different JavaScript module formats and has support for using the same configuration settings as Node.js to determine which format is used.
Tools that are oftern used to support TypeScript development
- The Node.js debugger is a useful way to inspect the state of applications as they are executed,
- The linter helps avoid common coding errors that are not detected by the compiler but that cause problems nonetheless,
- The unit test framework is used to confirm that code behaves as expected,
TypeScript can be debugged using the integrated debugger included in Visual Studio Code or using the debugger integrated into Node.js (Learn at 02 January 2023)
- Breakpoints can be created using the code editor or with the debugger keyword.
- The TypeScript linter checks TypeScript code for common problems.
- TypeScript relies on third-party frameworks, such as Jest, for unit testing.
Understanding static types (Learn at 03 January 2023)
- Restricting the range of types that can be as signed to variables or used in operations
- Relying on the compiler to infer types
- Using any, never, and unknown types to broaden or restrict the range of values
- Creating type unions that combine multiple types,
- Using type assertions and type guards to narrow types
- Controlling how the JavaScript null and undefined values can be used
Dukung Saya supaya tetap menulis artikel-artikel yang baik, membayar sewa domain, dan server untuk blog ini. Caranya dengan donasi cendol via Trakteer.id.
Komentar: 0
Login untuk meninggalkan komentar