Skip to content

Invalid Prototype Method #8

Open
@brittanydionigi

Description

@brittanydionigi

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions