Skip to content
Advertisement

TypeError: Cannot read property ‘toLowerCase’ of undefined error javascript [closed]

JavaScript

TypeError: Cannot read property ‘toLowerCase’ of undefined error

Advertisement

Answer

String.prototype.toLowerCase is for a string. Value prototypes don’t work on an undefined value (e.g: undefined.forEach or undefined.keys), nor do they work for values that don’t belong to that prototype of that value (e.g: "string".push).

This error means that you are calling .toLowerCase on a value that is undefined, so, using logic we can conclude that msg.content is undefined.

To fix it, I recommend some debugging (try to console.log msg if you can, and see what it contains).

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement