Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Note(name, text)
- {
- this.name = name;
- this.text = text;
- function displayNote()
- {
- alert(this.text);
- }
- }
- var note = new Note("a", "c");
- alert(note.displayNote);
- function Note(name, text)
- {
- this.name = name;
- this.text = text;
- function displayNote()
- {
- var self = this;
- alert(self.text);
- }
- }
- var note = new Note("a", "c");
- alert(note.displayNote);
- function Note(name, text)
- {
- this.name = name;
- this.text = text;
- this.displayNote = function()
- {
- alert(this.text);
- }
- }
- var note = new Note("a", "c");
- note.displayNote();// it will automatically alert. Otherwise you'll have two alerts. The second one being undefined.
- this.displayNote = function()
- {
- alert(this.text);
- }
- note.displayNote(); // Note the brackets to call.
- alert(note.displayNote);
- note.displayNote();
- <script language="javascript" type="text/javascript">
- <!--
- person = new Object()
- person.name = "Tim Scarfe"
- person.height = "6Ft"
- person.run = function() {
- this.state = "running"
- this.speed = "4ms^-1"
- }
- //-->
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement