learning javascript at the moment, stuck with inheritance. Question:
how can i inherit delay
function from first
function to second
with different text aka -var text
var first = (function () {
var text = "test!";
return {
delay: function(time) {
setTimeout(function() {
alert(text);
}, time)
}
}
})();
first.delay(400);
second.delay(1000);
function second() {
var text = 'second';
}
Do i need to use first.prototype.delay.call(this, time)
? I can't figure it out.
Or Do i need to create delay function like this: first.prototype.delay = function(time) {...} etc... ?
How can i achieve this? I guess i can do it in different approaches...