Page 1 of 1

Set Local Variable to number is NaN

Posted: Tue Apr 07, 2015 3:19 am
by George6656971

I do this:

Image

Then I do this:

Image

After that

temp = ""0""

and

startPageValue = NaN

Why?

Thanks in advance.

George


Set Local Variable to number is NaN

Posted: Tue Apr 07, 2015 11:56 am
by Bruce Stuart

Although only half an answer....and you likely already know this...but looks like your local storage value is not "0" but has two sets of quotes around it ""0"" ... So doing parseInt on it will indeed yield NaN ...since you are asking for the numeric value of a string of length 3 ... "0" ... Instead of a string of length 1 and value of 0 .

I'd go around using the visual editor to set the value and do it in a JavaScript localStorage.setItem ...

Best,
Bruce


Set Local Variable to number is NaN

Posted: Tue Apr 07, 2015 3:29 pm
by Serhii Kulibaba

Hello George,

Using a Storage variable with type=Number avoid additional verifications and convertings


Set Local Variable to number is NaN

Posted: Wed Apr 08, 2015 2:05 am
by George6656971

It is set to number type. So why does it end up as ""0""?


Set Local Variable to number is NaN

Posted: Wed Apr 08, 2015 3:18 am
by Bruce Stuart

I honestly do not trust storing anything to local storage as numeric ... It's unreliable and half the time the data when retrieved comes back as character ... To your implied point George!


Set Local Variable to number is NaN

Posted: Wed Apr 08, 2015 2:42 pm
by Serhii Kulibaba

You can also use file API but it is also unreliable


Set Local Variable to number is NaN

Posted: Thu Apr 09, 2015 1:56 am
by George6656971

A quick followup. I noticed that in the Appery.io documentation on Storage and Models it states, "We strongly recommend that you use the Appery.io Storage API when working with storage variables. Such an approach will guarantee that in the case of any changes on our side, the efficiency of your apps will not be affected" and recommends the Apperyio.storage.storageVariable.get/set api. However, in the forum here I don't see that being used or recommended. Why is that?

Thanks.


Set Local Variable to number is NaN

Posted: Thu Apr 09, 2015 11:57 am
by Serhii Kulibaba

We did not recommed use Appery.io storage uses local storage, session storage or window variables, because of you didn't want use these storage. You shouldn't save password anywhere for security.


Set Local Variable to number is NaN

Posted: Fri Apr 10, 2015 3:44 am
by George6656971

Sergiy,

???


Set Local Variable to number is NaN

Posted: Fri Apr 10, 2015 5:08 pm
by Serhii Kulibaba

Don't save passwords anywhere if you are worry about security. More information here:
http://stackoverflow.com/questions/12...
and here:
http://stackoverflow.com/questions/16...