|
If your objects have a known set of relevant properties, then you can just compare those. If you want to compare equality of containers like sets, for example, then you need to worry about keys that are present in either but not both. If you're dealing with JS objects that conform to a known protocol -- they have the same structural type -- then just do what you'd do in any language with explicit types.
|
# ? Dec 23, 2015 04:09 |
|
|
# ? May 17, 2024 14:31 |
|
Can somebody help point me in the direction of a Javascript framework that would work well for what I'm doing? The idea is that we'll have a rails app which is basically just an API, and a JS app (currently using Angular) handing an admin interface, and the user facing component. The problem with Angular is that it may be a bit heavy-handed for what we're doing. We don't really need two way binding, right now the Angular app uses API calls to update the Rails app DB. I'm just looking for suggestions based on anybody's experience, what they liked/didn't like. So far the list of possibilities include React, Reflux with Flux, and Knockout... I don't really have any criteria for what is best, other than ease of use, and performance(which is why I'm leaning towards React).
|
# ? Dec 29, 2015 20:43 |
|
no_funeral posted:So far the list of possibilities include React, Reflux with Flux, and Knockout... I don't really have any criteria for what is best, other than ease of use, and performance(which is why I'm leaning towards React). Reflux is a Flux library that sits on top of React, its a way of managing global state at the top level of the React component hierarchy. The general trend seems to be heading towards Redux, which does better at enforcing immutable state. Flux is an Architecture, thats it (though Facebook did release a dispatcher when they described the Flux architecture). Redux is based on this architecture but takes it a step further. I've been very happy working with React + Redux, and while there's no "framework" really built around these libraries yet they are pleasant to work with and have a small enough surface area to piece together on your own.
|
# ? Dec 29, 2015 21:42 |
|
necrotic posted:Reflux is a Flux library that sits on top of React, its a way of managing global state at the top level of the React component hierarchy. The general trend seems to be heading towards Redux, which does better at enforcing immutable state. Flux is an Architecture, thats it (though Facebook did release a dispatcher when they described the Flux architecture). Redux is based on this architecture but takes it a step further. Thanks, I've been watching the videos here https://egghead.io/lessons/javascript-redux-the-reducer-function and Redux + React seems like it will end up being my recommendation. Either that, or we dive into the Angular 2.0 beta because we all hate ourselves. I think the trouble I'm having with this is evaluating what our exact needs are (for a product that exists, but we're rebuilding it) and translating those into feature sets, and which would be most advantageous for us.
|
# ? Dec 29, 2015 21:58 |
|
Subjunctive, I have an early JS history question for you. Who the hell named it XMLHttpRequest, and how can I punch them over the internet? That consistency on capitalization is amazing.
|
# ? Jan 4, 2016 10:13 |
|
also, while you're at it, track down the guy who made getElementById and innerHTML too
|
# ? Jan 4, 2016 10:15 |
|
Microsoft created XHR for Outlook Web Access, to handle the HTTP requests once they stopped shipping Java. They also did innerHTML, I believe in the IE4 days when they first shipped Trident with a live DOM (which ruled) vs Netscape 4's layer-replacement model (which sucked). gEBI was probably some XML weenie on a W3C committee, at Boeing or a French defense contractor or something. It's of that era.
|
# ? Jan 4, 2016 13:26 |
|
You sure? I thought MS created ActiveXObject("XMLHTTP"), so they named it correctly.
|
# ? Jan 4, 2016 16:41 |
|
Suspicious Dish posted:You sure? I thought MS created ActiveXObject("XMLHTTP"), so they named it correctly. Oh, that inconsistent case. Yeah, uh, so like...that was us.
|
# ? Jan 4, 2016 18:20 |
|
The networking people were terrible at naming things and interface design. We used to describe it as a drawer of mismatched socks.
|
# ? Jan 4, 2016 18:21 |
|
how does something like that even happen without anybody catching it
|
# ? Jan 4, 2016 18:31 |
|
Please, you're triggering me.
|
# ? Jan 4, 2016 18:33 |
|
(Next time we get beer, I will tell you stories.)
|
# ? Jan 4, 2016 18:34 |
|
About XMLHttpRequest - I've heard that it's a strict naming scheme where if two or more acronyms are in a row, it must flip flop between upper and lowercase (but still start off with a capital) so it doesn't look like one giant acronym. I don't like it, and what excuse do the have for getElementById?
|
# ? Jan 12, 2016 21:01 |
|
No, it is not a principled thing. It was an internal-to-Gecko piece of bad naming that got exposed to the web and
|
# ? Jan 12, 2016 21:17 |
|
LP0 ON FIRE posted:About XMLHttpRequest - I've heard that it's a strict naming scheme where if two or more acronyms are in a row, it must flip flop between upper and lowercase (but still start off with a capital) so it doesn't look like one giant acronym. I don't like it, and what excuse do the have for getElementById? This problem is why I just do all acronyms in camel case now (eg XmlHttpRequest).
|
# ? Jan 12, 2016 22:28 |
|
I have an element that has nodeType 3, but I can't access its style property. What's the deal? It's a div. Edit: Arghh.. Why is it that just about anytime I post here asking something I wasted hours on, I immediately figure it out? I was using nextSibling, instead of nextElementSibling. LP0 ON FIRE fucked around with this message at 23:01 on Jan 12, 2016 |
# ? Jan 12, 2016 22:54 |
|
Template strings are pretty rad. That is all.
|
# ? Jan 20, 2016 08:11 |
|
Wheany posted:Template strings are pretty rad. That is all. Agreed. If I didn't already always use Babel for every JS probject, I'd start just so I can use template strings everywhere.
|
# ? Jan 20, 2016 17:48 |
|
I'm given this string and I'm trying to decide how to evaluated it:code:
Using collators makes this human readable comparison easier: code:
code:
obstipator fucked around with this message at 19:22 on Jan 22, 2016 |
# ? Jan 22, 2016 19:17 |
|
Use the semver package if you can via npm install semver. If you're working in a browser and not using a build system that allows you to use npm packages, maybe you can hack something together with the semver source. Parsing semantic version numbers is non-trivial.
|
# ? Jan 22, 2016 19:24 |
|
I think you're going to end up writing a parser and simple evaluator for the small language you want to process, so that you can give the operators the meanings you want.
|
# ? Jan 22, 2016 19:25 |
|
Piss. Parsers are too much for my wee brain to handle for a project this small. I'm just gonna regex some poo poo to convert the special weird cases into things I can evaluate easily.
|
# ? Jan 22, 2016 19:52 |
|
obstipator posted:Piss. Parsers are too much for my wee brain to handle for a project this small. I'm just gonna regex some poo poo to convert the special weird cases into things I can evaluate easily. http://jsep.from.so/
|
# ? Jan 22, 2016 20:28 |
|
obstipator posted:Piss. Parsers are too much for my wee brain to handle for a project this small. I'm just gonna regex some poo poo to convert the special weird cases into things I can evaluate easily. Using regex IS a parser.
|
# ? Jan 22, 2016 20:28 |
|
Skandranon posted:Using regex IS a parser. Expressed in one of the worst ways possible, though.
|
# ? Jan 22, 2016 20:32 |
|
Subjunctive posted:Expressed in one of the worst ways possible, though. Things can always be worse...
|
# ? Jan 22, 2016 20:34 |
|
Would y'all mind checking my work? A job I just applied for had a code test, to "write a JavaScript function that merges all its string arguments and returns the result", giving as an example pre:merge("abc", "123") == "a1b2c3"; ETA: I've already applied, so this isn't cheating, it's just for my own education. darthbob88 fucked around with this message at 08:41 on Jan 25, 2016 |
# ? Jan 25, 2016 08:39 |
|
darthbob88 posted:Would y'all mind checking my work? A job I just applied for had a code test, to "write a JavaScript function that merges all its string arguments and returns the result", giving as an example Unless I'm misunderstanding the prompt, couldn't you just do this: JavaScript code:
|
# ? Jan 25, 2016 14:43 |
|
That would be stupendously simple if arguments was an array. So let's make it one with Array.apply: function merge(){return Array.apply(null, arguments).join()} Boom. To be submitted you really need to check if an arguement can be converted into a string so you don't end up with a bunch of [Object object]s (and NaN's probably?) but at least its not using a nested loop to copy over one length strings one by one. edit: or be fancy like the guy above me.
|
# ? Jan 25, 2016 14:44 |
|
You've both misunderstood the prompt. Look at the example output darthbob88 supplied, your code doesn't do that.
|
# ? Jan 25, 2016 15:04 |
|
qntm posted:You've both misunderstood the prompt. Look at the example output darthbob88 supplied, your code doesn't do that. You're right. Yeah, I don't see an easier way of doing it then, my bad.
|
# ? Jan 25, 2016 15:11 |
|
well, I would first have asked them what happens when I hand them two strings of uneven length, because that seems like an obvious prompt and one they want you to ask.
|
# ? Jan 25, 2016 16:40 |
|
darthbob88 posted:Would y'all mind checking my work? A job I just applied for had a code test, to "write a JavaScript function that merges all its string arguments and returns the result" JavaScript code:
|
# ? Jan 25, 2016 17:24 |
|
Sedro posted:It is basically "zip" The point of the exercise is to show he can do the logic himself, not let Lodash handle everything. Yes in practice it's good not to reinvent the wheel, but sometimes you want to see if someone actually understands how a wheel works.
|
# ? Jan 25, 2016 17:29 |
|
Skandranon posted:The point of the exercise is to show he can do the logic himself, not let Lodash handle everything. Yes in practice it's good not to reinvent the wheel, but sometimes you want to see if someone actually understands how a wheel works.
|
# ? Jan 25, 2016 17:35 |
|
when did underscore get renamed to low-dash?
|
# ? Jan 25, 2016 18:43 |
|
Suspicious Dish posted:when did underscore get renamed to low-dash? When it got forked by someone who can design an API worth a drat.
|
# ? Jan 25, 2016 18:45 |
|
Suspicious Dish posted:when did underscore get renamed to low-dash? lodash has been the better alternative to underscore for years now. Yes, that's classic JS community for you.
|
# ? Jan 25, 2016 19:00 |
|
|
# ? May 17, 2024 14:31 |
|
I never really followed underscore / lodash because most of the utility functions seem nearly pointless or so obvious to write to not matter.
|
# ? Jan 25, 2016 19:02 |