Reputation: 358
I wrote the following logic
'use strict';
function F5 () {
}
F5.prototype.bang = function()
{
console.log("pew pew");
}
F5.bang();
execution falls short saying that 'F5.bang is not a function'
but it is. what did I write wrong?
Upvotes: 0
Views: 37
Reputation: 2609
Since F5 is a prototype, it must be initialized as an object in order to use prototype methods on F5. For example:
var abc = new F5();
abc.bang(); // pew pew
Upvotes: 1