Node is giving this error while checking the occurrence of a substring:
TypeError: Cannot read property 'indexOf' of undefined'
var withdraw = project.withdrawal;
var uemail = user.eamil;
var ans = withdraw.indexOf(uemail) > -1;
Node is giving this error while checking the occurrence of a substring:
TypeError: Cannot read property 'indexOf' of undefined'
var withdraw = project.withdrawal;
var uemail = user.eamil;
var ans = withdraw.indexOf(uemail) > -1;
console.log(withdraw)
and show result...
– uzaif
Commented
May 1, 2016 at 2:07
withdraw
variable is undefined
.
– Soubhik Mondal
Commented
May 1, 2016 at 2:08
project
doesn't have a withdrawal
property. (Or it does have a withdrawal
property, but that property's value is undefined
.)
– nnnnnn
Commented
May 1, 2016 at 2:09
user.ueamil
– Dave Pile
Commented
Nov 20, 2016 at 8:21
The variable withdraw is most likely undefined. Can you default it to an empty string with:
var withdraw = project.withdrawal || "";
That should avoid the error, but it might be better to check if there's another error causing withdrawal to be undefined.