codehag / js-better-errors

Let's discuss making better errors for JavaScript
MIT License
37 stars 2 forks source link

Invalid Prototype Method #8

Open brittanydionigi opened 5 years ago

brittanydionigi commented 5 years ago

What is the code triggering the message?

let pie = {
  flavor: 'rhubarb',
  size: 'large'
};

pie.push({ temperature: 'warm' });

What went wrong in the code? What is the system trying to tell you?

I'm trying to use an array prototype method on an object. (The prototype method I selected does not exist on the data type I'm calling it on.)

What error message do you see? Which JavaScript environment produced this error?

#### V8
TypeError: pie.push is not a function

What error message would you like to see?

TypeError: 'push' is not a valid method for the object 'pie'

(New developers tend to think the current error message means there's something wrong with push, rather than thinking to check the data type of the value they're working with. They'll try to capitalize push or change the prototype method to something else.)

Do you agree to license your suggested error message under an MIT-style license?

Yes