Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

OOPS in javascript

5,781 views

Published on

This presentation shows how to create simple objects in JavaScript.

Published in: Technology
  • 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

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 />

×