JavaScript 2022

Term 3 Wednesday

May - July 2022

This site will be updated live during the sessions

Week 8 8 Call 3

		
001// Example of call without args
		
002const theFirm = {
		
003  title: 'The Firm',
		
004  author: 'John Grisham',
		
005  yearOfRelease: 1991,
		
006  getYearOfRelease() {
		
007    return this.yearOfRelease;
		
008  },
		
009  introduceAuthor(message) {
		
010    return `${this.author} ${message}`;
		
011  },
		
012};
		
013
		
014console.log(theFirm.getYearOfRelease()); // prints 1991
		
015
		
016const theDaVinciCode = {
		
017  title: 'The Da Vinci Code',
		
018  author: 'Dan Brown',
		
019  yearOfRelease: 2003,
		
020};
		
021
		
022console.log(theFirm.getYearOfRelease.call(theDaVinciCode)); // prints 2003
		
023
		
024// Example of call with args
		
025
		
026console.log(theFirm.introduceAuthor('has written a total of 100 books'));
		
027
		
028console.log(theFirm.introduceAuthor.call(theDaVinciCode, 'is an American author best known for this thriller novels'))
		
029