Skip to content

Instantly share code, notes, and snippets.

@Maccauhuru
Created February 27, 2019 01:32
Show Gist options
  • Save Maccauhuru/e2166810cbf2aa675b80beab77de61ed to your computer and use it in GitHub Desktop.
Save Maccauhuru/e2166810cbf2aa675b80beab77de61ed to your computer and use it in GitHub Desktop.
Getters & Setters Example 1
const movie = {
name : "The Godfather",
year : 1972,
director: 'Francis Ford Coppola',
imdb_Rating: 9.2,
get movieDetails(){
return `
The movie : '${this.name}' was directed by ${this.director} and released in the year ${this.year}.
It has a very high IMDB Rating of ${this.imdb_Rating} / 10.
`
}
}
movie.movieDetails;
//The movie : 'The Godfather' was directed by Francis Ford Coppola and released in the year 1972.
//It has a very high IMDB Rating of 9.2 / 10.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment