js-better-errors icon indicating copy to clipboard operation
js-better-errors copied to clipboard

Invalid Prototype Method

Open brittanydionigi opened this issue 7 years ago • 0 comments

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

brittanydionigi avatar Oct 18 '18 23:10 brittanydionigi