extends vs implements in typescript

class Person {
  name: string;
  age: number;

  walk(): void {
    console.log('Walking (person Class)')
  }

  constructor(name: string, age: number) {
    this.name = name;
    this.age = age;
  }
}
class child extends Person { }

// Man has to implements at least all the properties
// and methods of the Person class
class man implements Person {
  name: string;
  age: number

  constructor(name: string, age: number) {
    this.name = name;
    this.age = age;
  }

  walk(): void {
    console.log('Walking (man class)')
  }

}

(new child('Mike', 12)).walk();
// logs: Walking(person Class)

(new man('Tom', 12)).walk();
// logs: Walking(man class)

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
typescript interface extends vs implements extends and implements in typescript difference between extends and implements in typescript? angular implements vs extends typescript difference between extends and implements angular ts extends vs implements extends or extends typescript typescript class extends and implements difference between extends and implements in typescript extends implements typescript class implements and extends in ts typescript interface implements vs extends typescript extends vs implements class implements extends typescript typescript extends implements typescript difference between implements and extends ts implements and extends ts extends vs implements implements and extends typescript typescript implements extends ts implements vs extends implement vs extend ts implements vs extends typescript what is the difference between class extends and class implements typescript typescript extends and implements both typescript implments extends vs implements interface typescript implements class typescript implements keyword in angular typescript extends vs implement typescript what is implement typescript extend vs implement implements javascript implements vs extends in javascript typescript "implement" vs "extend" typescript implement vs extend typescript extends vs implements typescript typescript implements vs extends difference between implements and extends in typescript what is the difference between implements and extends in typescript typescript implements extends vs implements in typescript
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source