JavaScript Program Create a function called Club. It will have one argument, the
ID: 3699843 • Letter: J
Question
JavaScript Program
Create a function called Club. It will have one argument, the name of the new Club. Instead of creating a new Object, it will use the special variable this and manually modify/hack it to add the property "name" which will store the club name. Run your function using new, as if your function was a Class like in JAVA / C++. Store your new object in a variable. Finally, console.log( your_variable_here instanceof Club ). This is javascript's way check the 'type' of an object.
Output:
console.log() trueExplanation / Answer
function Club(name) { this.name = name; } var club = new Club('real madrid'); console.log( club instanceof Club );
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.