TypeScript Modifiers The TypeScript supports to multiple modifiers and it is by default public. 1. Public, 2. Private, 3. Protected and 4. Read-only Public by default! Stayed Informed – Learn Angular 2 with TypeScript Public Modifier – Public by default! It is freely access anywhere. In the below example, the class Employee and its members are by default public and we are freely access it. Example – class Employee { empName: string ; constructor (name: string ) { this .empName = name; } salary(salary: number = 10000 ) { console.log( 'Hello, ' + this .empName + ' Your Salary -' + salary); } } let empSal = new Employee( "Anil" ); console.log(empSal.salary()); console.log(empSal.salary( 40000 )); Private Modifier - When using private modifier, we can’t be accessed from outside of its containing class. E...
Angular, React, JavaScript, Java, PHP, SQL, C#, Vue, NodeJs, TypeScript and Interview Questions Answers