February 2019
Beginner
694 pages
18h 4m
English
JavaScript provides the bind, call, and apply functions that are used when we need to override the value of the this variable inside a function. We have already seen the use of the apply function in our discussion on decorators in Chapter 4, Decortators, Generics and Asynchronous Features. We will discuss the use of the bind function in detail in Chapter 7, TypeScript Compatible Frameworks. The strictBindCallApply compiler option can be used to ensure that the parameters that are used in any of these calls are type safe. To illustrate this concept, consider the following code:
class MyBoundClass { name: string = "defaultNameValue"; printName(index: number, description: string) { console.log(`this.name : ${this.name}`); ...Read now
Unlock full access