Deon
Posts: 0
Joined: Sun Jun 30, 2013 6:00 am

if statement not working

Hi
I have and if statement which is a standard statement I use throughout all my app to check for undefined values in local storage.
This standar statement is now not working in one of my apps. To test I have put alerts in all over the show. Only the first alert before the statement is displayed with a result of undefined. When the if statement executes. Noting happens.
Unfortunatly I cant test my app to see what is wrong because your testers now dont allow mix of http and https which is another problem.Image

leven.steve
Posts: 0
Joined: Sun Mar 04, 2012 4:01 pm

if statement not working

Deon, I feel your pain the same way when things change/stop working.

I've been using the Lodash library which Appery includes by default in the apps.
Assuming you've got it included you could try using the Lodash function
.isUndefined() like if(.isUndefined(userreg)) {...}

See here https://lodash.com/docs/4.16.4#isUnde...

This is a test output:
code
//On load screen logic
console.log("Starting...");
var x;
var y=0;
var z="&quot

console.log("x="+x);
console.log("y="+y);
console.log("z="+z);

console.log("x:"+.isUndefined(x));
console.log("y:"+.isUndefined(y));
console.log("z:"+_.isUndefined(z));

console.log(typeof x);
console.log(typeof y);
console.log(typeof z);
/code

And the output in the console is this:
Starting...
x=undefined
y=0
z=
x:true
y:false
z:false
undefined
number
string

So use the Lodash function or try (if typeof userreg===undefined) {...}

See also here http://davidbcalhoun.com/2011/checkin...

Deon
Posts: 0
Joined: Sun Jun 30, 2013 6:00 am

if statement not working

Thanks for your reply Steve

I am really balling to test my app now since the tester upgrades. All my app access non http remote databases. So I cant do any testing. Gotta create an apk binary every time I want to test. So frustrating.

Anyway, I found the issue. It was a service that executed before the js caused the problem. Its funny and confusing that the 1stpart of the js got executed before the crash yet the part from the if statement bombed.

I will check out the lodash lib. Thanks for the tip and assistance.

Return to “Issues”