Question · JavaScript and TypeScript course · Module 5: Advanced JavaScript
Object Methods in Practice
How do you add a method to an object in JavaScript?
Answer options
- const raptor = { hunt() { return "hunting"; } };
- All of the above
- const raptor = { hunt: function() { return "hunting"; } };
- const raptor = { hunt: () => "hunting" };
You can check the correct answer by solving this task in the CodeWorlds game.