Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. function Note(name, text)
  2. {
  3. this.name = name;
  4. this.text = text;
  5.  
  6. function displayNote()
  7. {
  8. alert(this.text);
  9. }
  10. }
  11.  
  12. var note = new Note("a", "c");
  13. alert(note.displayNote);
  14.  
  15. function Note(name, text)
  16. {
  17. this.name = name;
  18. this.text = text;
  19.  
  20. function displayNote()
  21. {
  22. var self = this;
  23. alert(self.text);
  24. }
  25. }
  26.  
  27. var note = new Note("a", "c");
  28. alert(note.displayNote);
  29.  
  30. function Note(name, text)
  31. {
  32. this.name = name;
  33. this.text = text;
  34.  
  35. this.displayNote = function()
  36. {
  37. alert(this.text);
  38. }
  39. }
  40.  
  41. var note = new Note("a", "c");
  42. note.displayNote();// it will automatically alert. Otherwise you'll have two alerts. The second one being undefined.
  43.  
  44. this.displayNote = function()
  45. {
  46. alert(this.text);
  47. }
  48.  
  49. note.displayNote(); // Note the brackets to call.
  50.  
  51. alert(note.displayNote);
  52.  
  53. note.displayNote();
  54.  
  55. <script language="javascript" type="text/javascript">
  56. <!--
  57.  
  58. person = new Object()
  59. person.name = "Tim Scarfe"
  60. person.height = "6Ft"
  61.  
  62. person.run = function() {
  63. this.state = "running"
  64. this.speed = "4ms^-1"
  65. }
  66.  
  67. //-->
  68. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement