Page 1 of 1

property length is undefined in javascript?

PostPosted: Thu May 17, 2012 5:43 pm
by juan.cristobo
Hi, I have this code:

Code: Select all
/**
  * @type {JSDataSet}
*/
var dataset = databaseManager.getDataSetByQuery(...);

if(dataset.getValue(1,5).length < 6) {
...
}


I receive this warning:

Code: Select all
property length is undefined in javascript


How can I do to set the type of dataset.getValue(1,5) (it's a string value)?

Thanks,

Re: property length is undefined in javascript?

PostPosted: Fri May 18, 2012 1:09 am
by sbutler
Well, the value could be null, so you should check it first, like:

Code: Select all
if(dataset.getValue(1,5) && dataset.getValue(1,5).length < 6) {
...
}

If your curious to see what the type is, use:

Code: Select all
application.output(typeof dataset.getValue(1,5))