Skip to content

Instantly share code, notes, and snippets.

@icarcal
Created April 30, 2018 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icarcal/dfb8ebc632977ec339794160ae3c5347 to your computer and use it in GitHub Desktop.
Save icarcal/dfb8ebc632977ec339794160ae3c5347 to your computer and use it in GitHub Desktop.
var rick = 'Rick';
var morty = 'Morty';
var earth = 'C31';
function rickAndMorty() {
// global context
console.log(`These ${this.rick} & ${this.morty} belongs to earth ${this.earth}`);
}
var earthC39 = {
rick: 'Rick',
morty: 'Morty',
earth: 'C39',
rickAndMorty: function rickyAndMorty() {
// earthC39 object context
console.log(`These ${this.rick} & ${this.morty} belongs to earth ${this.earth}`);
}
}
rickAndMorty();
// These Rick & Morty belongs to earth C31
earthC39.rickAndMorty();
// These Rick & Morty belongs to earth C39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment