Your SlideShare is downloading. ×
0
Prototype & Inheritance in JavaScript
Prototype & Inheritance in JavaScript
Prototype & Inheritance in JavaScript
Prototype & Inheritance in JavaScript
Prototype & Inheritance in JavaScript
Prototype & Inheritance in JavaScript
Prototype & Inheritance in JavaScript
Prototype & Inheritance in JavaScript
Prototype & Inheritance in JavaScript
Prototype & Inheritance in JavaScript
Prototype & Inheritance in JavaScript
Prototype & Inheritance in JavaScript
Prototype & Inheritance in JavaScript
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Prototype & Inheritance in JavaScript

2,174

Published on

What is prototype and how we use it to inherit the properties of an object in JavaScript.

What is prototype and how we use it to inherit the properties of an object in JavaScript.

Published in: Technology
0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,174
On Slideshare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
123
Comments
0
Likes
7
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Prototype & Inheritance in JavaScript C# Corner – 21st September Sunny Kumar
  • 2. Prototypes in JavaScript • What is Prototype? • Augmenting the Prototype • Overwriting the Prototype • Use of Prototype • Prototype Chain Inheritance in JavaScript • Various ways of Inheritance in JavaScript.
  • 3. Sneak Peek into past… Functions - are objects. - returns Value. - can return objects, including other functions. - they have properties. - they have methods. - can be copied, deleted, augmented. - special feature: Invokable. - when invoked with new keyword, returns an object named this , can be modified before it’s returned.
  • 4. Sneak Peek into past… Constructor Functions var Person = function(name) { this.name = name; this.getName = function() { return this.name; }; }; var me = new Person(“Sunny"); me.getName(); // “Sunny"
  • 5. • prototype is a property of function object. • Only function Objects can have prototype property.
  • 6. var foo = function(){}; console.log(foo.prototype); Object {} //output
  • 7. Var foo=function(){}; Var myFoo = new foo(); //instantiates an object of foo. foo.prototype.MaxValue=100; foo.prototype.SayHello=function(name){ return “Hi “+name+” !”; } myFoo.SayHello(“Kumar”); // “Hi Kumar !”
  • 8. foo.prototype={x:1,y:2}
  • 9. var Person = function(name) { this.name = name; }; Person.prototype.say = function(){ return this.name; };
  • 10. var dude = new Person('dude'); dude.name; // "dude“ dude.say(); // "dude“ same result

×