how to cast in javascript code example
Example 1: javascript type casting int
Number("3.14") // returns 3.14
false.toString() // returns "false"
String(false) // returns "false"
Example 2: javascript casting objects
class Person {
constructor(obj) {
obj && Object.assign(this, obj);
}
getFullName() {
return `${this.lastName} ${this.firstName}`;
}
}