George6656971
Posts: 0
Joined: Wed Feb 12, 2014 5:05 am

Set Local Variable to number is NaN

I do this:

Image

Then I do this:

Image

After that

temp = ""0""

and

startPageValue = NaN

Why?

Thanks in advance.

George

Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

Set Local Variable to number is NaN

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

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Set Local Variable to number is NaN

Hello George,

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

George6656971
Posts: 0
Joined: Wed Feb 12, 2014 5:05 am

Set Local Variable to number is NaN

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

Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

Set Local Variable to number is NaN

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!

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Set Local Variable to number is NaN

You can also use file API but it is also unreliable

George6656971
Posts: 0
Joined: Wed Feb 12, 2014 5:05 am

Set Local Variable to number is NaN

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.

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Set Local Variable to number is NaN

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.

George6656971
Posts: 0
Joined: Wed Feb 12, 2014 5:05 am

Set Local Variable to number is NaN

Sergiy,

???

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Set Local Variable to number is NaN

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...

Return to “Issues”