|
HORATIO HORNBLOWER posted:Just fixed a 'for in' bug this morning. Code looked like this: I don't really know JavaScript - is the implication here that "for (x in collection)" iterates not only over the elements of the collection, but also all of its methods/fields/etc?
|
# ? Mar 7, 2014 20:09 |
|
|
# ? May 11, 2024 08:52 |
|
Otto Skorzeny posted:Here's a recent one-liner bugfix:
|
# ? Mar 7, 2014 20:16 |
|
ToxicFrog posted:I don't really know JavaScript - is the implication here that "for (x in collection)" iterates not only over the elements of the collection, but also all of its methods/fields/etc? Essentially. JavaScript doesn't really have "collections" per se, it just has objects, which have properties (or fields, whatever). A method is just a property whose value is a function. Misleadingly, an array is just an object like any other. It has at least one property of its own (length) and you can set more properties if you want. It's just that - effectively - some of the properties are very small integers starting at 0. "for (x in object)" is intended to iterate over the properties of an object. When you apply it to an array, you do get all of the values from the array, but you get other things as well, as mentioned. To iterate over an array's elements, you want this.
|
# ? Mar 7, 2014 20:31 |
|
ToxicFrog posted:I don't really know JavaScript - is the implication here that "for (x in collection)" iterates not only over the elements of the collection, but also all of its methods/fields/etc? JavaScript objects are just a hash/dictionary, and a for loop iterates over the keys. (And their prototype's keys. And their prototype's prototype's keys. ...) Arrays usually work ok because they intentionally withhold their other properties from iteration. IE 8 apparently returns an almost-but-not-quite-like-Array object from document.getElementsByTagName that forgot to hide its length property.
|
# ? Mar 7, 2014 20:51 |
|
JavaScript arrays are definitely goofier than I expected:MDN posted:When setting a property on a JavaScript array when the property is a valid array index and that index is outside the current bounds of the array, the engine will update the array's length property accordingly:
|
# ? Mar 7, 2014 20:53 |
|
GrumpyDoctor posted:JavaScript everything is definitely goofier than I expected There we go.
|
# ? Mar 7, 2014 20:56 |
|
HORATIO HORNBLOWER posted:
I think the real horror here is using for-in on an array. (Sorry, a NodeList!)
|
# ? Mar 7, 2014 21:38 |
|
Adahn the nameless posted:There's a good chance I'm not understanding your ajax problem fully, but couldn't you just chain promises? Tried that. There's some deeply buried labyrinthine issue with events that nobody has been able to catch in the time we could spare to look. Since our current workaround, well, works, it's on the back burner. I'm trying to not think about when this is going to bite us in the rear end.
|
# ? Mar 7, 2014 21:58 |
|
pseudorandom name posted:The theory is that transaction reissue was entirely automated. AFAIK, part of the code dump was the function that automatically re-issued transactions that didn't make it but with a higher fee. I don't know if that was out when Sirer was writing that blog post.
|
# ? Mar 7, 2014 22:07 |
|
qntm posted:One row in the table represents one minimal unit of currency. You can't have fewer than 0 rows, right? That's exactly the kind of weirdness I come up with
|
# ? Mar 7, 2014 22:09 |
|
I still work here and don't want to get fired, so I'm going to remove this code for now. It's too obviously this peron's code. Sorry.
TastySauce fucked around with this message at 23:14 on Mar 7, 2014 |
# ? Mar 7, 2014 23:07 |
|
GrumpyDoctor posted:JavaScript arrays are definitely goofier than I expected: Given that you can resize arrays by just assigning where you want, and without initializing all elements, that behavior all makes perfect sense to me.
|
# ? Mar 8, 2014 03:23 |
|
necrotic posted:I think the real horror here is using for-in on an array. (Sorry, a NodeList!) Well that's kind of the point, though. An array is iterable so you'd expect for-in to work with it just fine. But there's so many gotchas with the construct in JavaScript that it's best just to avoid it.
|
# ? Mar 8, 2014 03:25 |
|
GrumpyDoctor posted:JavaScript arrays are definitely goofier than I expected:
|
# ? Mar 8, 2014 03:49 |
|
JS might look like a real language, but don't be fooled. It's just some prat's unfinished hack interpreter from 1995.
|
# ? Mar 8, 2014 04:01 |
|
Hey, he did a pretty good job for the two weeks that were allotted to the project.
|
# ? Mar 8, 2014 04:03 |
|
pseudorandom name posted:Hey, he did a pretty good job for the two weeks that were allotted to the project. The rule is prototypes always get promoted to production.
|
# ? Mar 8, 2014 04:13 |
|
I'm fairly sure they knew it was destined for production from the beginning.
|
# ? Mar 8, 2014 04:23 |
|
The entire point of the ten-day deadline was to get it into production before the alternative far worse scripting language being worked on.
|
# ? Mar 8, 2014 04:36 |
|
GrumpyDoctor posted:JavaScript arrays are definitely goofier than I expected: Time is a flat circle
|
# ? Mar 8, 2014 04:49 |
|
necrotic posted:I think the real horror here is using for-in on an array. (Sorry, a NodeList!) NodeList is type of Object generated by the DOM, but it has no inherit properties of an Array. `for (x in obj)` is mainly used by Javascript Objects and not for arrays. And the only reason you'd have to keep using it is for backwards compatibility with older browsers. Otherwise you just iterate over Object.keys()
|
# ? Mar 8, 2014 04:57 |
|
Plorkyeran posted:The entire point of the ten-day deadline was to get it into production before the alternative far worse scripting language being worked on. Could you elaborate? I've never heard that there was something even worse than JavaScript that was being pushed and Wikipedia and Google aren't turning anything up.
|
# ? Mar 8, 2014 05:21 |
|
I think it was VBScript
|
# ? Mar 8, 2014 05:36 |
|
Mr.Radar posted:Could you elaborate? I've never heard that there was something even worse than JavaScript that was being pushed and Wikipedia and Google aren't turning anything up. tractor fanatic posted:I think it was VBScript
|
# ? Mar 8, 2014 06:18 |
|
HORATIO HORNBLOWER posted:Well that's kind of the point, though. An array is iterable so you'd expect for-in to work with it just fine. But there's so many gotchas with the construct in JavaScript that it's best just to avoid it. Yeah. To be honest I never use it. ES5 shim and iterator methods is my preferred.
|
# ? Mar 8, 2014 07:44 |
|
PHP: The Good Parts
|
# ? Mar 8, 2014 08:11 |
|
Mr.Radar posted:Could you elaborate? I've never heard that there was something even worse than JavaScript that was being pushed and Wikipedia and Google aren't turning anything up. I think it was going to be Tcl. There was an article about it on the 20th anniversary of the language, but I can't find it any more. The best I've got is two paragraphs in http://sdt.bz/31644.
|
# ? Mar 8, 2014 12:20 |
|
Budum-tsssh
|
# ? Mar 8, 2014 12:25 |
|
Plorkyeran posted:The entire point of the ten-day deadline was to get it into production before the alternative far worse scripting language being worked on. Wait, JS was written in 10 days to avoid a terrible scripting language from becoming a standard? Did they really not see the error in this logic?
|
# ? Mar 10, 2014 16:04 |
|
By 1995 standards, JS is pretty awesome. It was the first "mainstream" language with first-class functions and good object/array literals, and while I'm not a huge fan of prototype inheritance, it's better than nothing. Just compare JS to VBScript 1.0 (which came after JS) to see how much worse it could have been.
|
# ? Mar 10, 2014 16:24 |
ES6 is going to be even more awesome http://code.tutsplus.com/tutorials/eight-cool-features-coming-in-es6--net-33175 I love JavaScript
|
|
# ? Mar 10, 2014 18:11 |
|
down with slavery posted:ES6 is going to be even more awesome I look forward to never being able to use any of this because everyone will still need to retain compatibility with older browsers. Also that "object decomposition" thing looks like a horror.
|
# ? Mar 10, 2014 19:18 |
|
Dessert Rose posted:I look forward to never being able to use any of this because everyone will still need to retain compatibility with older browsers. What, destructuring? Destructuring is amazing. Once you get used to it you feel straightjacketed without it.
|
# ? Mar 10, 2014 19:23 |
|
Anyone have a recommended tutorial/book for programmers trained in Java who keep loving up the usage of C strings in just about every possible way?
|
# ? Mar 10, 2014 19:54 |
Dessert Rose posted:I look forward to never being able to use any of this because everyone will still need to retain compatibility with older browsers. IE 8 and IE 9 are really the only things left holding on to the whole "support every browser" crap. How long do you expect their life cycle to last?
|
|
# ? Mar 10, 2014 19:55 |
|
Dren posted:Anyone have a recommended tutorial/book for programmers trained in Java who keep loving up the usage of C strings in just about every possible way? Learn valgrind, make mistakes, and please don't use C.
|
# ? Mar 10, 2014 19:56 |
|
GrumpyDoctor posted:What, destructuring? Destructuring is amazing. Once you get used to it you feel straightjacketed without it. Yes, replacing names with implicit numeric labels is certainly an improvement.
|
# ? Mar 10, 2014 20:00 |
|
Dessert Rose posted:I look forward to never being able to use any of this because everyone will still need to retain compatibility with older browsers. Well if you used node for all of your server programming you could use them today! Or at release. Or whatever.
|
# ? Mar 10, 2014 20:17 |
down with slavery posted:ES6 is going to be even more awesome That is not eight features, and not all of them are cool.
|
|
# ? Mar 10, 2014 20:39 |
|
|
# ? May 11, 2024 08:52 |
|
Dessert Rose posted:I look forward to never being able to use any of this because everyone will still need to retain compatibility with older browsers. https://github.com/google/traceur-compiler
|
# ? Mar 10, 2014 20:48 |