« first day (1826 days earlier)      last day (3123 days later) » 

11:00 PM
Is there any way to force a javascript variable to a data type ?
 
crl
js is kinda not very strongly typed, what is your example?
 
i am adding a float like so: obj.property += parseFloat(myFloat);
i was hoping it would assume that i am not adding a string
but it decides to add strings
 
crl
!!> var obj={};obj.property = parseFloat('1.2'); obj;
 
@crl {"property":"NaN"}
 
that seems correct to me ^
 
crl
11:04 PM
well you're doing +=
 
giving property is not set to a value yet
does += only add strings?
 
@crl {"property":1.2}
 
crl
+= increments, or concatenates for strings
 
yeah but if i am using parseFloats i'd half thought JS would know i'm using numbers not strings
 
crl
basically with += you were doing obj.property = undefined + parseFloat(...)
 
11:06 PM
it only knows string + float = string
 
my property was set before i was doing +=
it was a float
 
crl
to a string or float?
 
you sure?
prove it
 
if it wasn't my canvas would not be working ctx.scale
 
crl
!!> var obj={property : 3.2};obj.property += parseFloat('1.2'); obj;
 
11:07 PM
as soon as the type is string my canvas breaks
 
@crl {"property":1.2}
 
not good evidence
 
@crl {"property":4.4}
 
well certain actions suddenly make scale go from correct floats to 1.21.31.4 etc
so for some reason it switches to strings i've no idea why
 
crl
you forgot to convert to Float somewhere
 
11:08 PM
+= parseFloat should surely maintain the data type right ?
 
or some other library did
probably you
 
i'm checking to see if i missed a parseFloat
 
that reminds me, i wonder if facebook flow supports es6, yet.
 
crl
that's where class setters are useful (Proxy does that?) you just have to check at one place
 
you can use setters without any proxy bs in IE9+
I vote against a setter. it'll hide the problem by parsing strings
so if it get promoted to a string and appended to, it'll just get parsed and everything after the second decimal point discarded
 
11:15 PM
@user2997204 Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
5 messages moved to Trash can
Kicked, he's likely to return, will kick again.
 
If only he'd phrase it in the form of a question we could have helped.
probably didn't even search main..
 
At least he didn't ask to ask
 
the ultimate evil
 
ok i narrowed it down to this:

console.log('Test: '+typeof(result)); //number
console.log('Test 2: '+ typeof(self.scale)); // number
self.scale = parseFloat(result).toFixed(2);
console.log('Test 3: '+ typeof(self.scale)); // string
 
11:20 PM
Look up toFixed on mdn
 
i'm guessing toFixed is the cause
ah, darn it! is there a function that returns a number by default ?
instead of string for decimal fixing
 
No, but you can define it
 
Okay, i'm surprised it doesn't return the same data type it was given to be honest.
 
crl
!!> var d=1e3;/*3 dec*/; var x=1.123456; Math.floor(d*x)/d;
 
@crl 1.123
 
11:29 PM
"potential mountain views" sure, dude. redfin.com/WA/Seattle/1634-S-Lane-St-98144/home/144861
 
crl
@Zirak there's no api key for weather command, right? it seems now they need one api.openweathermap.org/data/2.5/weather jsbin.com/yewefe/edit?html,js,output
A: Starting from 9 October 2015 our API requires a valid APPID for access. Note that this does not mean that our API is subscription-only now - please take a minute to register a free account to receive a key.

We are sorry for inconvenience but this is a necessary measure that will help us deliver our services to you faster and more reliably.
oh, we could ask for one
that command isn't essential though
that reminds me I need to implement JWT on my app
 
11:50 PM
!!> var x = 1.2345678; Math.round(x*100)/100
 
@Luggage "ReferenceError: assignment to undeclared variable x"
@Luggage 1.23
 
cc @Pheonixblade9
 
@Luggage wha'cha trying to prove ?
 
that i can multiply a number by 100
Success!
 
wth
 
11:53 PM
ohh, wrong person, that snippet was fro @Dave
 
so, you wanna keep only 2 decimal places?
 
he does, without converting it to a string like toFixed does
not sure why
i mean, i know why he doesn't want a string, but not the two decimal places
 
i currently made a function to divide by 1 after using toFixed
seems to convert it back to number
 
!!>var x=42.9237897; (x*1e2|1)/1e2
 
@CSᵠ That didn't make much sense. Use the !!/help command to learn more.
 
11:55 PM
because type coersion worked so well for you up until now :)
 
@CSᵠ 42.93
 
lol true :P
 
crl
!!should I sleep?
 
@crl Certainly
 
!!should you reconsider?
 
11:57 PM
@CSᵠ Yes, absolutely
 
crl
!!how_old is Zirak?
 
@crl I'm 16.
 
crl
oh shit, need to improve that command
 
!!moshoboner
 

« first day (1826 days earlier)      last day (3123 days later) »