I went through some JS code last day, but I couldn't understand. Here is the code
var data = {
name : 'Mr John',
age : '29',
location : 'New York',
profession : 'Accoutant'
};
var allowedNull = [];
for (var i in data) {
if (!data[i])
{
if (allowedNull.indexOf(i) < 0)
{
console.log('Empty');
}
}
}
The script actually prints "Empty" in console if the data
has an empty property. I just wanted know, how it works by calling indexOf
on allowedNull
. Can somebody explain how this works.
Fiddle : Check