« first day (1775 days earlier)      last day (3398 days later) » 

user406009
19:06
Too many people don't know about that second form despite how useful it is.
pretty sure @Jhoopins knows about it
user1596138
@Lalaland How would I use that to solve my problem...
user1596138
I am genuinely curious
user1596138
I don;t see how it applies :P
heh it only fires when the state is "actually" changed.. which would cause the rerender anyway.. which isn't happening
so I am confused as well :p
user1596138
19:08
Immutable mixins are the ticket, it makes sense now
user1596138
!!afk smoke
y/w wish I mentioned that in slack
user1596138
@Lalaland thanks for helping me see the problem
user406009
@Jhoopins this.setState has the possibily of race conditions. The last this.setState in the render cycle "wins".
user406009
19:09
The second form allows you to perform atomic transactions.
user406009
Sorta similar to STM thoery.
user1596138
All I heard was
user1596138
> atomic atomic atomic
user1596138
Tbh don't see how it applies, but thanks for helping
user406009
Darn. I hate this phone keyboard.
user406009
19:10
Here is a simple example:
I need a vaping device; quitting smoking right now, for the half-dozenth time
user406009
You call this.setState({a:this.state.a+1}); twice really fast.
user406009
This results in two calls: this.setState({a:1}); this.setState({a:1});
user406009
assuming state = {a:0} at the start.
user406009
Note how you lost an update.
user406009
19:12
Due to the possibiliy of state this.state.
user406009
stale*
user406009
this.setState((prevState) => ({a: prevState.a+1})) does the right thing.
@Lalaland sure, but it would still update regardless.
you're changing a's value from 0 to 1
in his case there was no update happening
user406009
Sometimes it's hard to tell the difference between no update and losing an update.
user406009
Due to minor changes.
19:17
I suppose, but that would assume the data went to new data then back to old
which could have been happening as well I guess
I'm in a bad mood today fixing a devs code who is no longer here.
stuff like this is so fun to see
summaryTables.length && summaryTables.forEach((table, index, tables) => {
let go today?
another one?
high turnover?
@rlemon lol no I mean today Im fixing the code
does letting go count as turnover?
can't hold him back any more?
wanna build a snowman?
I fixed my statement :p
19:18
@Loktar ahh
There we go worded it even more appropriately
like what is the point of array.length && before a call to forEach?
user406009
Perhaps he is using .length instead of Array.isArray?
its always an array and its not even wrapped in a condition
not particularily helpful
since strings have length
like... that line is the line of code
19:20
it serves no real purpose, since if the array had a length of 0, no function inside of the foreach would fire. Maybe he was trying to save the code a trip down that (very short) lane
but who knows
I blame @Jhoopins
The dev didn't know you could do let blah = bool && dataForBlah Jhoopins showed him.
jpoopins
so I'm thinking he was like oh cool new trick gonna use it here!
this guy was a contractor, right?
yea
19:22
strange
I'm having contractions from the contractor
user406009
I hate that techinique because of JavaScript's sucky truth table.
user406009
'' == false and all that.
an empty string should be falsey
nothing wrong there
just never use loose equals, and you'll be fine
user406009
No. Only false and null should be false.
19:24
an empty string isn't false
it's falsey
user406009
@Nick But then people use the stupid && trick.
that's not stupid
I wouldn;t use it in production
but it isn't stupid
user406009
Perhaphs I am just annoyed because I just fixed a bu where '' || 'default' broke some code.
ayy @rlemon your method for multiplying arrays works like a charm
user406009
When you used an empty string.
19:26
@Lalaland I'd much rather use a ternary in production code, but shortcuts are useful while debugging or testing silly things out
@corvid ofc it did. :D
although, I do use var foo = emptystring || 'something else'
@Codepenisbetter z
short circuit evaluation inside of a condition is mostly understood.
outside, kinda hacky
user406009
We need a zip function in JavaScript.
19:27
if you don't understand || and && it isn't the code that is too complicated, you need to learn operators.
user406009
For [1, 2] , [3, 4] -> [[1,3], [2,4]]
(not directed at anyone, just in general)
user406009
@rlemon The problem is that too many things are falsely.
@Lalaland I'm pretty sure we can do that with destructuring in es6
@Lalaland Array.prototype.concat ??
user406009
19:28
Leading to bugs.
@Lalaland no
@rlemon how?
@JanDvorak nvm, I misread
I thought he flattened it
false
0
<empty string>
null
undefined
NaN
these are not hard to remember imo
but meh
user406009
Empty string and 0 lead to issues.
19:30
only if you expect them and still test for falsey
user406009
They are both valid values in most instances.
I see back end devs here all the time not understand truthy/falsey, so they write if (foo !== undefined && foo !== null)
which is just silly
not always
user406009
That should be foo != null.
user406009
The one valid use of == or !=.
19:31
if( typeof arg !== 'undefined' ) { }
@JanDvorak in the cases that I see it used, it is
@Lalaland no, don't use ==
@Nick I can beat that, I maintained some code that had (foo == null || foo == undefined)
@rlemon == null is perfecly fine
I respectfully disagree
user406009
19:32
@rlemon It's a special case.
@rlemon yesterday you said you weren't interested in using angular, what do you use?
@rlemon Yeah, it was that, actually. checking if the typeof was undefined or null... that's just bizarre
@NathanJones vanilla everything, and jquery
user406009
(And PHP)
user406009
(It's his secret pleasure)
19:32
@rlemon do you have any apps on github i could look at?
I haven't written PHP in such a long time
@NathanJones no
user406009
/s
@Lalaland also known as masochism
I haven't written real php in about a year and a half
@NathanJones node + express + ejs
is what I use
I do all data binding by myself
I don't recommend it
I'm just stupid
19:33
I agree with @Lalaland
Angular is only useful if you're looking for a job in california
user406009
Angular is fine. React is just better.
I don't like angular hardly at all
I'll be honest, I haven't given Angular the time of day.. I might like it once I get into it, but I really don't like the idea of writing my front end that way.
i can't learn anything because i'm afraid something new will supersede it
user406009
19:35
Most concepts carry over.
Although, had to do .map((n) => parseInt(n)) to get it to return as a number
I'm just not the biggest fan of SPA. I like having a front end and a back end that do their jobs. I'm not a fan of my back end only sending back json; seems a bit dirty to me
@NathanJones Welcome to JS
@corvid you should pass a radix to parseInt, also that probably doesn't work. nvm I misread
user406009
@Nick What about serverside rendering?
19:37
Yeah, I know you can get your server to pre-render your react or angular; I'm perfectly ok with that
@rlemon it appears to work, why do you say it shouldn't?
but you should still pass a radix
or just use Number
arr.map(parseInt) doesn't work because parseInt expects a radix
.map(n => Number(n))
19:38
no
pls
doesn't line up 1:1
parseInt is better, more clear as to what you're doing
!!> parseInt("123px", 10)
@rlemon 123
19:39
!!> Number("123px")
and parseInt should always receive a radix
@rlemon "NaN"
user406009
What about the glorious + operator? /ducks
!!>Number('100')
Well, I was asuming his numbers were just in strings, not with extra thingies attached
19:39
@corvid 100
@rlemon JavaScript is really broken
@Lalaland don't use type coercion
yeah I started with an array of numbers, those numbers became strings, now I am mapping them back to numbers
yea then Number works
@corvid ew
user1596138
19:41
@ssube Psh
user406009
Things should't magically become strings.
user1596138
!!> parseInt('0123')
@Jhoopins "SyntaxError: octal literals and octal escape sequences are deprecated"
@Jhoopins 123
user1596138
Oh right, modern browsers
!!> Number((1.239534289789).toFixed(2))
19:43
@Nick 1.24
number -> string is a common scenario for js
and then back to number
it's also easily avoided
!!> 1.239534289789.toString()
@rlemon "1.239534289789"
user406009
@Nick I think you're thinking of PHP.
user406009
19:45
JavaScript isn't that loose.
@Lalaland Nah, I remember when I was making a cash register in JS -- sometimes it did require that I convert my number -> string -> number in order to format it correctly
with the correct rounding and number of digits/places after 0
@Nick that's not right
I just wish there was a lodash way to do this... but I can't find a repeat function
Feel free to educate me
you should never have to go from number to string and back
19:48
alright, then show me
take 1.239534289789 and turn it into 1.24
!!> Number.prototype.round = function(places) { var shift = Math.pow(10, places); return Math.round(this * shift) / shift; }; console.log(1.239534289789.round(2));
@ssube "SyntaxError: missing ; before statement"
@ssube "undefined" Logged: "NaN"
@ssube "undefined" Logged: 1.24
@ssube ew
arbitrary-length rounding polyfill
Hey, even Jan says ew
19:51
Hi!
Jan says ew to anything that works
that's true
it's not a polyfill if the standard never defined it
back from holidays
@ssube no
19:51
how did computers work?
but anyways, since there's nothing for that normally, you just shift it by factors of 10 and round
I run into so many weird problems with arrays :\
still better than using strings
user1596138
19:52
    React.addons.update(this.state, {
        USA: {$merge: toSet},
        Canada: {$merge: toSet}
    });
user1596138
Derp did it
user1596138
Thanks @Lalaland @Loktar
you're welcome
user1596138
FU @Nick
user1596138
19:53
:)
@ssube wondering if the division step could mess things up
user1596138
Oh wait hahaha that's broken syntax
user1596138
But yeah basically. You get the idea
@JanDvorak the whole thing can mess things up, it's floating-point arithmetic
it's still more reliable and much, much, much faster than going to a string, finding the dot, truncating via substr, and parsing back
I think the string version is more reliable
19:57
are we still talking about the repeating of an array?
would there be any issue ? if I have my angular view declared as .

fruitInCrate ?

atm I am getting 404 as it's not loading my scripts and html files,

fruitInCrate
- fruitInCrate.html
- fruitInCrate.js
its loading rest of controllers as usual, not just this one
but why are you putting fruits in a crate? That's cruel.
@corvid just for your satisfaction, let say it's called waterInBottle :)
water doesn't belong in a bottle, it belongs in the ocean where it can be free :(
I am not even sure what to search for on google, i mean what would be the keywords

« first day (1775 days earlier)      last day (3398 days later) »