Guest User

Untitled

a guest
Dec 6th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. function summonHero (name, position) {
  2. return {
  3. say: function (sentence) {
  4. alert(sentence);
  5. },
  6. move: function (position) {
  7. console.log('Moving to x=' + position.x + ' and y=' +position.y);
  8. this.pos = position;
  9. },
  10. name: name,
  11. pos: position
  12. };
  13. }
  14.  
  15. var ana = summonHero('Ana', {x:0,y:0});
  16. console.log(ana.say('hello'));
  17. console.log(ana.pos);
  18. console.log(ana.move({x:10,y:10}));
  19. console.log(ana.pos);
Add Comment
Please, Sign In to add comment