OOPS in javascript

5,581 views
5,467 views

Published on

This presentation shows how to create simple objects in JavaScript.

Published in: Technology
2 Comments
3 Likes
Statistics
Notes
  • really simple & useful.....
    thanks for sharing
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Great slide show for beginners...Keep it up.Expect in-depth tutorials in future.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
5,581
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
163
Comments
2
Likes
3
Embeds 0
No embeds

No notes for slide

OOPS in javascript

  1. 1. OOPS in Javascript<br />part 1<br />
  2. 2. object?<br />
  3. 3. object?<br />instance of a type<br />
  4. 4.
  5. 5. instance of type dart frog<br />
  6. 6.
  7. 7. instances of type walrus<br />
  8. 8. object?<br />instance of a type<br />type represents anything a dart frog or a walrus<br />
  9. 9. how to create objects?<br />
  10. 10. how to create objects?<br />let’s start with creating a type… say ‘dartfrog’<br />
  11. 11. how to create objects?<br />let’s start with creating a type… say ‘dartfrog’<br />vardartfrog= function(){}<br />
  12. 12. how to create objects?<br />let’s start with creating a type… say ‘dartfrog’<br />vardartfrog= function(){}<br />type<br />
  13. 13. adding properties <br />andbehaviors<br />
  14. 14. properties<br />vardartfrog= function(){<br />this.name = ‘’;<br />this.color = ‘’;<br />this.poisonous = true;}<br />
  15. 15. properties<br />vardartfrog= function(){<br />this.name = ‘’;<br />this.color = ‘’;<br />this.poisonous = true;}<br />properties<br />
  16. 16. properties<br />let’s fill the properties at the time of creation by passing values.<br />vardartfrog= function(name, color, poisonous){<br />this.name = name;<br />this.color = color;<br />this.poisonous = poisonous;}<br />
  17. 17. behaviors<br />vardartfrog= function(name, color, poisonous){<br />this.name = name;<br />this.color = color;<br />this.poisonous = poisonous;<br />this.jump = function(){<br />alert(“JUMP JUMP JUMP”); } ;<br />this.sing = function(){<br />alert(“CROAK CROAK CROAK”); } }<br />
  18. 18. behaviors<br />vardartfrog= function(name, color, poisonous){<br />this.name = name;<br />this.color = color;<br />this.poisonous = poisonous;<br />this.jump = function(){<br />alert(“JUMP JUMP JUMP”); } ;<br />this.sing = function(){<br />alert(“CROAK CROAK CROAK”); } }<br />Methods or behaviors<br />
  19. 19. let’s create some frogs <br />and make them sing<br />
  20. 20. creating objects<br />varjackstraw = newdartfrog(“jackstraw”, <br /> “strawberry”,<br /> true);<br />
  21. 21. creating objects<br />varjackstraw = newdartfrog(“jackstraw”, <br /> “strawberry”,<br /> true);<br />name<br />color<br />poisonous?<br />
  22. 22. creating objects<br />varjackstraw = newdartfrog(“jackstraw”, <br /> “strawberry”,<br /> true);<br />varstickyellow= newdartfrog(“stickyellow“,<br /> “yellow”,<br /> true);<br />varblueman= newdartfrog(“blueman“,<br />“blue”,<br /> true);<br />
  23. 23. calling methods<br />Guys are you ready. come on sing!!<br />jackstraw.sing();<br />stickyellow.sing();<br />blueman.sing();<br />CROAK CROAKCROAK<br />CROAK CROAKCROAK<br />CROAK CROAKCROAK<br />
  24. 24. ThankYou<br />

×