Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Angular for .NET Developers

You're reading from   Learning Angular for .NET Developers Develop dynamic .NET web applications powered by Angular 4

Arrow left icon
Product type Paperback
Published in Jun 2017
Publisher Packt
ISBN-13 9781785884283
Length 248 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
 Gunasundaram Gunasundaram
Author Profile Icon Gunasundaram
Gunasundaram
Arrow right icon
View More author details
Toc

Table of Contents (10) Chapters Close

Preface 1. Getting Started with Angular 2. Angular Building Blocks - Part 1 FREE CHAPTER 3. Angular Building Blocks - Part 2 4. Using TypeScript with Angular 5. Creating an Angular Single-Page Application in Visual Studio 6. Creating ASP.NET Core Web API Services for Angular 7. Creating an Application Using Angular, ASP.NET MVC, and Web API in Visual Studio 8. Testing Angular Applications 9. What s New in Angular and ASP.NET Core

Inheritance


Inheritance is the concept of inheriting some behaviors of another class or object. It helps achieve code reusability and build hierarchy in relationships of classes or objects. Also, inheritance helps you cast similar classes.

JavaScript of ES5 standard doesn't support classes, and so, class inheritance is not possible in JavaScript. However, we can implement prototype inheritance instead of class inheritance. Let's see inheritance in ES5 with examples.

First, create a function named Animal, as follows. Here, we create a function named Animal with two methods: sleep and eat:

var Animal = function() { 
    this.sleep = function() { 
       console.log('sleeping'); 
    } 
    this.eat = function() { 
       console.log('eating'); 
    } 
} 

Now, let's extend this Animal function using the prototype, as shown:

Animal.prototype.bark = function() { 
    console.log('barking'); 
} 

Now, we can create an instance of Animal and call the extended function bark, as demonstrated:

var a = new...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime