Skip to content

Instantly share code, notes, and snippets.

@mageddo
Last active March 7, 2016 18:44
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 mageddo/12702f0d08e8b495efec to your computer and use it in GitHub Desktop.
Save mageddo/12702f0d08e8b495efec to your computer and use it in GitHub Desktop.
Javascript "Lambdas"
// with functions
var Person = function() {
this.say = message => console.log('you said: ', message);
this.getOnHand = (hand1, hand2) => {
console.log(hand1, 'at left hand');
console.log(hand2, 'at right hand');
}
};
var p1 = new Person();
p1.say('Hello!');
p1.getOnHand('Apple', 'Orange');
// with functions
var Person = {
say: message => console.log('you said: ', message),
getOnHand: (hand1, hand2) => {
console.log(hand1, 'at left hand');
console.log(hand2, 'at right hand');
}
};
Person.say('Hello!');
Person.getOnHand('Apple', 'Orange');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment