var computer = { | |
accessWeb : function(site) { | |
// Đi tới site nào đó | |
console.log ('Go to: ' + site); | |
} | |
}; | |
var oldFunction = computer.accessWeb; | |
// Tráo function accessWeb bằng hàm mới | |
computer.accessWeb = function() { | |
console.log('Con gà bắt đầu vào web'); | |
oldFunction.apply(this, arguments); // giữ nguyên hàm cũ | |
console.log('Con gà đã vào web'); | |
} | |
computer.accessWeb('thiend*a.com'); | |
// Con gà bắt đầu vào web | |
// Go to: thiend*a.com | |
// Con gà đã vào web |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment