Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function summonHero (name, position) {
- return {
- say: function (sentence) {
- alert(sentence);
- },
- move: function (position) {
- console.log('Moving to x=' + position.x + ' and y=' +position.y);
- this.pos = position;
- },
- name: name,
- pos: position
- };
- }
- var ana = summonHero('Ana', {x:0,y:0});
- console.log(ana.say('hello'));
- console.log(ana.pos);
- console.log(ana.move({x:10,y:10}));
- console.log(ana.pos);
Add Comment
Please, Sign In to add comment