Skip to content

Instantly share code, notes, and snippets.

@savelee
Created July 26, 2016 07:09
Show Gist options
  • Save savelee/9e26fc84b5316c1fdbb607e897c1ac4a to your computer and use it in GitHub Desktop.
Save savelee/9e26fc84b5316c1fdbb607e897c1ac4a to your computer and use it in GitHub Desktop.
Enhanced Object literals
//ES2015
function getVideoGame(title, version, platform) {
return {
title,
version,
platform
};
}
getVideoGame("Uncharted", "4", "PS4")
/* returns:
{
title : "Uncharted",
version: "4",
platform: "PS4"
}
*/
//ES5
function getVideoGame(t, v, p) {
return {
title : t,
version: v,
platform: p
};
}
getVideoGame("Uncharted", "4", "PS4")
/* returns:
{
title : "Uncharted",
version: "4",
platform: "PS4"
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment