Skip to content

Instantly share code, notes, and snippets.

@jose4125
Created August 25, 2016 17:59
Show Gist options
  • Select an option

  • Save jose4125/37e1f5ddcc74bcd160de799fde749c81 to your computer and use it in GitHub Desktop.

Select an option

Save jose4125/37e1f5ddcc74bcd160de799fde749c81 to your computer and use it in GitHub Desktop.
console.log('========================== OTHER PROTOTYPAL ================================')
var Proto2Task = {
title: 'title',
isComplete: false
}
Object.defineProperties(Proto2Task, {
complete: {
value: function() {
return this.isComplete;
}
},
msg: {
value: function() {
console.log(this.title + ' is ' + (this.isComplete ? 'completed' : 'not completed yet'));
}
}
})
var myPr2Task = Object.create(Proto2Task, {
title:{value: 'task1'}
});
console.log('my pr2', myPr2Task)
console.log('my pr2 complete', myPr2Task.complete())
console.log('my pr2 complete', myPr2Task.msg())
var myPr2Task2 = Object.create(Proto2Task, {
title: {value: 'task2'},
isComplete: {value: true}
});
console.log('my pr2 2', myPr2Task2)
console.log('my pr2 2', myPr2Task2.msg())
var UrgentProto2Task = Object.create(myPr2Task, {
title: {
value: 'urgent task'
},
typeTask: {
value: 'urgent'
}
});
Object.defineProperties(UrgentProto2Task, {
msg: {
value: function() {
console.log(Proto2Task.msg.call(this) +
', but this is ' + this.typeTask)
}
}
})
var myUrgPr2Task = Object.create(UrgentProto2Task);
console.log(myUrgPr2Task)
console.log(myUrgPr2Task.msg())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment