|
Wheany posted:Sure, but it doesn't support poo poo like Array.from, requestAnimationFrame and MutationObserver, all of which I used in this script. The first two I could circumvent with Array.prototype.whatever.call() and setTimeout(,0), but the last bit I just had to comment out. If it's just a user script and not an extension you just have to check developer mode and drag the .user.js file in to the extensions window. Then it will show up normally in developer tools under sources (I forget which sub tab of sources it will be under, probably just sources).
|
# ? May 15, 2015 18:00 |
|
|
# ? Jun 5, 2024 08:13 |
|
Depressing Box posted:Is this it? Yeah, that worked
|
# ? May 16, 2015 19:30 |
|
I know it was asked on the last page, but http://www.regex101.com has saved my rear end hundreds of times when I need to be certain that I got my matching right.
|
# ? May 17, 2015 20:34 |
|
Anyone know of a good ical parsing library for Node? I'm using ical, but am getting bit hard by this bug, wherein the library parses the event in the system's local time (UTC), even though the event is listed in US/Mountain. I can use moment-timezone and parse every call to event start/stop times in the correct timezone (yuck; this means passing a 'timezone' for every calendar I want to parse), but I'm hoping someone might know of a more elegant solution/better ical client library.
|
# ? May 18, 2015 22:01 |
|
Dangerllama posted:Anyone know of a good ical parsing library for Node? I'm using ical, but am getting bit hard by this bug, wherein the library parses the event in the system's local time (UTC), even though the event is listed in US/Mountain. I think mozilla's ical.js is pretty complete: https://github.com/mozilla-comm/ical.js/
|
# ? May 18, 2015 22:18 |
How would you represent a table with N row headers and N col headers in a way amenable to render it with angular?pre:+-------+------------------------+-------------------+ | | 2014 | 2015 | | +----+----+----+----+---------+----+----+----+ | | 1 | 4 | 5 | 6 | 12 | 3 | 4 | 5 | 10 | +---+------------------------------------------------+ | | | | | | | | | | | | | U |NY | 80 | 87 | 83 | 82 | 84 | 94 | 63 | 42 | 64 | | S +------------------------------------------------+ | A | | | | | | | | | | | | |WA | 80 | 73 | 95 | 73 | 73 | 84 | 64 | 75 | 85 | | +------------------------------------------------+ | | | | | | | | | | | | | |OR | 74 | 74 | 74 | 74 | 83 | 54 | 75 | 53 | 74 | +-------+----+----+----+----+----+----+----+----+----+
|
|
# ? May 19, 2015 14:48 |
|
The only way to ensure order is using arrays, objects in Javascript are not ordered. For a 2D grid, use a 2-dimensional array where the first dimension is rows and the second is columns.
|
# ? May 19, 2015 16:27 |
|
necrotic posted:The only way to ensure order is using arrays, objects in Javascript are not ordered. For a 2D grid, use a 2-dimensional array where the first dimension is rows and the second is columns.
|
# ? May 19, 2015 16:50 |
|
necrotic posted:The only way to ensure order is using arrays, objects in Javascript are not ordered. For a 2D grid, use a 2-dimensional array where the first dimension is rows and the second is columns. Objects and Arrays can both have numbered properties, which can be looped over with for. The only real difference between Arrays and Objects is that Arrays maintain a length property.
|
# ? May 19, 2015 18:22 |
In the end the boss solved it with a node tree.
|
|
# ? May 19, 2015 20:41 |
|
Subjunctive posted:Objects and Arrays can both have numbered properties, which can be looped over with for. The only real difference between Arrays and Objects is that Arrays maintain a length property. http://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf quote:4.3.3 Object So, sure, you can use numbers if you want. But the order is not guaranteed! You may experience behavior that makes it look like it is, but the spec doe not require it and browsers do behave differently.
|
# ? May 20, 2015 16:36 |
|
necrotic posted:So, sure, you can use numbers if you want. But the order is not guaranteed! You may experience behavior that makes it look like it is, but the spec doe not require it and browsers do behave differently. Arrays aren't ordered either, you just access their numeric properties in order by looping from 0 to length; you can do the same with an Object. See 15.4 of the ES5 spec, or the specification of things like Array.prototype.forEach which explicitly count from 0 to length. 12.6.4 explicitly says that the enumeration order is not specified, and that holds for all objects including Arrays. I think you're confusing JSON's (non-)guarantees about the order that properties appear in serializations with some inherent property order for Arrays.
|
# ? May 20, 2015 17:07 |
|
That is true, but every engine special-cases for (var i in arr) because existing web applications depend on property iteration order of arrays.
|
# ? May 20, 2015 18:21 |
|
Subjunctive posted:Arrays aren't ordered either, you just access their numeric properties in order by looping from 0 to length; you can do the same with an Object. See 15.4 of the ES5 spec, or the specification of things like Array.prototype.forEach which explicitly count from 0 to length. 12.6.4 explicitly says that the enumeration order is not specified, and that holds for all objects including Arrays. Right, but if you care about order why would you use an Object with numeric keys instead of an Array (which gives you forEach that is ordered, whereas Object.keys().forEach would not be)? The only case I could see using an Object over an Array is if your starting index isn't 0 or something (since every index before N would "exist" as undefined).
|
# ? May 20, 2015 19:34 |
|
Suspicious Dish posted:That is true, but every engine special-cases for (var i in arr) because existing web applications depend on property iteration order of arrays. Actually, engines switched to numeric order because it fit into optimized storage setups. Previously, arrays were objects in how they stored properties, and shared Objects' enumeration order (which was was property addition order by de facto standard, pending ES4 de jure standardization, and on that topic there is a lot of remaining compatibility baggage today). Moving to dense vectors for (most) Array storage meant either tracking property addition order separately, or enduring some compatibility breakage by enumerating numeric properties in numeric order regardless of the order in which they were added. I broke a few sites with Firefox 3 when I did that, but we decided to roll with it. necrotic posted:Right, but if you care about order why would you use an Object with numeric keys instead of an Array (which gives you forEach that is ordered, whereas Object.keys().forEach would not be)? The only case I could see using an Object over an Array is if your starting index isn't 0 or something (since every index before N would "exist" as undefined). My point was more that Arrays aren't standardized to be ordered, so "they're ordered" isn't a reason to use them over Objects in this case. You might well have an object from another context, for example. But your starting index claim is not true either; if you don't set a property on an array it doesn't exist either, per keys() or in: JavaScript code:
|
# ? May 20, 2015 19:43 |
|
Subjunctive posted:
You can just put a mess of unseparated commas in an array literal? That's new to me.
|
# ? May 20, 2015 20:18 |
|
qntm posted:You can just put a mess of unseparated commas in an array literal? That's new to me. Yeah, array literals can represent holes.
|
# ? May 20, 2015 21:11 |
|
I remember when some code of one of my coworkers was 'broken by' a new Chrome version when it stopped enumerating object properties in numeric (or maybe insertion?) order and he made a big deal about it because his objects-as-sparse-arrays wouldn't work right anymore. IIRC he 'solved' it by packing real arrays with false where there was no data and for some reason he was originally forming keys by multiplying the page number by 1000 and storing the items on the page in the first 1000 numbers which eventually collapsed when someone tried to display a 100-page document.necrotic posted:Right, but if you care about order why would you use an Object with numeric keys instead of an Array (which gives you forEach that is ordered, whereas Object.keys().forEach would not be)? The only case I could see using an Object over an Array is if your starting index isn't 0 or something (since every index before N would "exist" as undefined). Because you're a PHP developer and that's how it works there so that's how every other language must work, right?
|
# ? May 20, 2015 21:26 |
|
Munkeymon posted:I remember when some code of one of my coworkers was 'broken by' a new Chrome version when it stopped enumerating object properties in numeric (or maybe insertion?) order and he made a big deal about it because his objects-as-sparse-arrays wouldn't work right anymore. IIRC he 'solved' it by packing real arrays with false where there was no data This is especially ridiculous given that Arrays handle sparseness just fine.
|
# ? May 20, 2015 21:28 |
|
CoffeeScript code:
This is for being able to multiselect drag and drop items. The idea is you add the other selected elements to the initial objects data, then retrieve them once the drag release event (stop) fires. the ui.item.data('multidrag') call in the stop block is undefined, and appears to work just fine before the end of the custom helper function, i.e. if i check item.data('multidrag') while I'm still inside of the custom helper, I see it.
|
# ? May 21, 2015 01:11 |
|
Thanks everyone for the help so far. Rewrote all the code, managed to actually get results. Haven't figured out what test situation will utterly destroy my code but we'll get there when we get there. However, this'll probably just end up being a way for me to track my progress in learning all the html elements and attributes and I won't purposefully try and break it, though I should. https://htmlpreview.github.io/?https://github.com/TravisBumgarner/Codesaurus/blob/master/index.html
|
# ? May 21, 2015 03:24 |
|
Subjunctive posted:Actually, engines switched to numeric order because it fit into optimized storage setups. Previously, arrays were objects in how they stored properties, and shared Objects' enumeration order (which was was property addition order by de facto standard, pending ES4 de jure standardization, and on that topic there is a lot of remaining compatibility baggage today). Moving to dense vectors for (most) Array storage meant either tracking property addition order separately, or enduring some compatibility breakage by enumerating numeric properties in numeric order regardless of the order in which they were added. I broke a few sites with Firefox 3 when I did that, but we decided to roll with it. I definitely remember some V8 engineer complaining about how when they didn't enumerate arrays in numeric order, a lot of sites broke.
|
# ? May 21, 2015 03:51 |
|
Suspicious Dish posted:I definitely remember some V8 engineer complaining about how when they didn't enumerate arrays in numeric order, a lot of sites broke. Possibly if they didn't enumerate numeric before non-numeric? Maybe sites have come to expect numeric order, but I didn't think IE always did that until 11.
|
# ? May 21, 2015 07:51 |
|
Subjunctive posted:But your starting index claim is not true either; if you don't set a property on an array it doesn't exist either, per keys() or in: Ah, I could've sworn it was. Thanks for the correction. Munkeymon posted:Because you're a PHP developer and that's how it works there so that's how every other language must work, right? I haven't worked with PHP in over 6 years, so no. rear end. edit: My confusion on sparse arrays came from JSON-ifying them necrotic fucked around with this message at 18:08 on May 21, 2015 |
# ? May 21, 2015 18:05 |
|
necrotic posted:edit: My confusion on sparse arrays came from JSON-ifying them Yeah, JSON doesn't permit holes in arrays; I have no idea what the rationale was for that.
|
# ? May 21, 2015 21:29 |
|
Doug Crockford is on record that he doesn't consider sparse arrays to be one of JavaScript's good parts, and besides that JSON targets languages other than JavaScript.
|
# ? May 22, 2015 06:22 |
|
is doug still on tc39 or have people realized that he's sort of a big hack by unironically inventing a new fixed number format in 2015?
|
# ? May 22, 2015 07:32 |
|
AFAIK he's still active.
|
# ? May 22, 2015 12:03 |
|
If I have a type inheriting from another type, how do I find out which properties are defined on the parent or the child?
|
# ? May 24, 2015 13:32 |
|
Boz0r posted:If I have a type inheriting from another type, how do I find out which properties are defined on the parent or the child? If I'm understanding you correctly you want hasOwnProperty. ...or If you don't care whether its inherited or not you can just do if ('someprop' in myObj)
|
# ? May 24, 2015 13:38 |
|
I'll check it out. I'm looking to get a list of the properties defined in the parent, and a list of the properties defined in the child. EDIT: It doesn't work properly, I think I need some help. code:
Boz0r fucked around with this message at 14:31 on May 24, 2015 |
# ? May 24, 2015 13:43 |
|
Boz0r posted:I'll check it out. I'm looking to get a list of the properties defined in the parent, and a list of the properties defined in the child. Oh sorry, try Object.keys
|
# ? May 24, 2015 14:32 |
|
Subjunctive posted:AFAIK he's still active. I'm actually just listening to an Eich presentation where he says that Crockford doesn't attend anymore. https://www.youtube.com/watch?v=u56b_HUj47E e: for some reason the time cue got messed up when SA converted the video link, it should be at 12m30s for the relevant bits
|
# ? May 26, 2015 12:14 |
|
Is there any practical reason or circumstance where I should useJavaScript code:
JavaScript code:
|
# ? May 28, 2015 17:16 |
|
qntm posted:Is there any practical reason or circumstance where I should use In ES6 you export functions from modules by naming them. And you can use the name of the function to recurse.
|
# ? May 28, 2015 20:10 |
|
Subjunctive posted:This is especially ridiculous given that Arrays handle sparseness just fine. Almost everyone at that job thought JavaScript worked just like C. It was an especially lovely environment to learn the language.
|
# ? May 28, 2015 20:33 |
|
qntm posted:Is there any practical reason or circumstance where I should use Function declarations are hoisted, while the assignment of a function expression's result to a variable only occurs when that line of code is reached. Assigning an anonymous expression result requires the developer to think about the ordering of their source in a way that simple declarations don't.
|
# ? May 28, 2015 20:40 |
|
Wheany posted:In ES6 you export functions from modules by naming them. Regarding your first point, does it count if I name functions like so? JavaScript code:
JavaScript code:
Subjunctive posted:Function declarations are hoisted, while the assignment of a function expression's result to a variable only occurs when that line of code is reached. Assigning an anonymous expression result requires the developer to think about the ordering of their source in a way that simple declarations don't. OK. Since in my second example the variable a would be hoisted (even if its value isn't), I think in practice that amounts to "don't call a function until it's been defined", which I can live with...?
|
# ? May 28, 2015 23:27 |
|
qntm posted:OK. Since in my second example the variable a would be hoisted (even if its value isn't), I think in practice that amounts to "don't call a function until it's been defined", which I can live with...? The variable being hoisted doesn't really help with anything, since there's no static checking of names. "Until it's been defined" can be hard to reason about, in the presence of things like onload scheduling. It doesn't always mean "later in source order", such as with mutually-recursive functions. TBH I'm not sure why you'd want to introduce that complexity (and explain why you type the name twice, or what it means for variable and function names to be different) rather than start with the simpler and more common form.
|
# ? May 29, 2015 00:24 |
|
|
# ? Jun 5, 2024 08:13 |
|
qntm posted:And for your second point, this works fine: Yeah, that works, but if you name the function, recursion also works in situations like this: JavaScript code:
JavaScript code:
|
# ? May 29, 2015 07:30 |