Class and Object in TypeScript || Using Object in Class
In this video,I explained how to use object in class in TypeScript. Feel free to comment. For more, please subscribe and press the BELL icon. Please visit my Angular Playlist . Please visit my YouTube Video. The code is as follows -
object.ts -
class Point { // Point - class
x: number;
y: number;
draw (){
console.log('X:- ' + this.x + ', Y:- '+ this.y + ', X + Y :- ' + (this.x + this.y) );
}
}
let point = new Point ; // point - Object
point.x = 50;
point.y = 100;
point.draw();
object.ts -
class Point { // Point - class
x: number;
y: number;
draw (){
console.log('X:- ' + this.x + ', Y:- '+ this.y + ', X + Y :- ' + (this.x + this.y) );
}
}
let point = new Point ; // point - Object
point.x = 50;
point.y = 100;
point.draw();
Comments
Post a Comment