|
My least favorite JavaScript "typo" is when something wants you to make a variable either camel case or dash case depending on the context. So even though your JavaScript and your HTML have the same variable name, it's not correct and acts like your variable doesn't even exist.
|
# ¿ May 16, 2017 03:03 |
|
|
# ¿ May 10, 2024 17:03 |
|
With new and different bugs.
|
# ¿ Sep 27, 2017 02:10 |
|
Does anyone have a good training video or such on RxJS and observables etc? Because they make me feel dumb and I am just copying and pasting code from the web to get stuff done. I just wrapped my head around promises and now they are old news.
|
# ¿ Nov 30, 2017 00:34 |
|
If I have an ES6 class, is there any difference between: method(param) { } And method = (param) => { }
|
# ¿ Dec 22, 2017 00:08 |
|
Sounds like you could use a Partial here? https://netbasal.com/getting-to-know-the-partial-type-in-typescript-ecfcfbc87cb6
|
# ¿ Feb 20, 2018 12:50 |
|
If you have an object coming from the backend as JSON would you make that a class or an interface in TypeScript? It seems like it’s basically just cast from the JSON so even if you make it a class you don’t get any class methods with it.
|
# ¿ Apr 16, 2018 13:06 |
|
Use WebStorm?
|
# ¿ Aug 10, 2018 13:14 |
|
huhu posted:Each time a new image is passed to the Image component, I want its color value to be included in the theme which OtherComponent and BarView could import from. Would there be a best practice for achieving something like this? If theme.js is just a non-component container for an object you are mutating, I’m not sure the sub components would re-render when you update it. Is there a common parent to all the components that use the theme? Maybe you can put the theme as a prop on that? smackfu fucked around with this message at 15:28 on Sep 3, 2018 |
# ¿ Sep 3, 2018 15:24 |
|
Our linting rules (which are generally in sync with AirBnb) require you to use the default export if there is only one export from a file. This seems well intentioned but in practice you often add another export in a future commit and then have to change everyplace the original default export was used. Argh.
|
# ¿ Sep 17, 2018 13:08 |
|
I know we have a lot of self taught JavaScript people who used to do Java and their understanding of JavaScript complexities is perhaps... lacking.
|
# ¿ Nov 13, 2018 04:38 |
|
Nolgthorn posted:Even faster calculate the length ahead of time Reminds me of code from 20 years ago. (Unless length is actually calculated on demand, doubtful this is an improvement at all.)
|
# ¿ Dec 3, 2018 13:58 |
|
necrotic posted:Nah, map(Number) is great. Its equally explicit and easier to read. I’m not a huge fan of the readability because it doesn’t look like a function with the uppercase.
|
# ¿ Dec 21, 2018 13:50 |
|
Nolgthorn posted:Why does eslint "recommend" 2 space tabbing? Eslint's rules are insane based on that. Of course you can change the default rules but what’s the problem with it?
|
# ¿ Dec 24, 2018 14:01 |
|
Roadie posted:Don't forget the true galaxy brain approach: I actually saw some similar code yesterday in a package we are using. code:
What the heck?
|
# ¿ Feb 2, 2019 16:54 |
|
Interesting, I figured they were using stringify to validate the user-provided JSON but couldn’t figure out why they were then parsing and using the result.
|
# ¿ Feb 2, 2019 18:04 |
|
We have an internal dependency that takes a mandatory id parameter for one function. Currently, if you forget the parameter, it will error out randomly deep in the code when it calls toString on an undefined id. What’s a typical way to handle this in JavaScript? Throw an error or console warn (or throw and warn)? smackfu fucked around with this message at 01:13 on Feb 7, 2019 |
# ¿ Feb 7, 2019 01:09 |
|
The worst is when someone converts an ISO date into a date time of midnight UTC on that date (for instance by passing it to parse), then the local time zone is negative (like US ones) so the displayed date ends up one day earlier than you started with.
|
# ¿ Feb 8, 2019 04:28 |
|
A good date-time library allows you to choose whether you want a local date, a local time, or an absolute date time, since there are use cases for all of them.
|
# ¿ Feb 8, 2019 14:04 |
|
I think the suggestion was that Unix timestamp is sufficient for all problems but it would generally give the unexpected result for a repeating meeting after a DST change.
|
# ¿ Feb 10, 2019 15:18 |
|
One of our junior devs used parseInt on an iso date to get the year. How do you even come up with that?
|
# ¿ Feb 10, 2019 23:08 |
|
Tip posted:It's the top answer on stack overflow. Oh yeah, a stack overflow question and answer from 2010. That’s probably good JavaScript advice in TYOOL 2019. quote:using the Date object is just an overkill, and should be avoided since the ISO-8601 format is not widely supported -yet-, quote:Hint: Try it on IE8 or below, and even in old Firefox versions, it simply will not work..
|
# ¿ Feb 11, 2019 14:00 |
|
Tip posted:I wasn't saying, "it's the top answer on stack overflow, therefore the most correct!" Didn’t think that at all, I was just rolling my eyes at the whole stack overflow page. Advice not to use a standard does not age well.
|
# ¿ Feb 12, 2019 02:41 |
|
Isn’t arguments more like an array than an object?
|
# ¿ Feb 17, 2019 14:37 |
|
Isn’t your use case extraordinarily rare?
|
# ¿ Mar 17, 2019 23:08 |
|
YO MAMA HEAD posted:labels, i think: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/label WebStorm loves to give syntax errors related to labels when you have a random typo like missing braces. I have never used labels so it’s really barking up the wrong tree.
|
# ¿ May 15, 2019 12:53 |
|
IAmKale posted:Some people run ESLint and Prettier side-by-side and I still don't "get it". Isn't ESLint with a sane ruleset like Airbnb's sufficient for ensuring code quality? What does Prettier do that eslint --fix won't? I think there’s an eslint confit that turns off all the formatting rules for that situation, so they don’t fight.
|
# ¿ May 23, 2019 03:45 |
|
roomforthetuna posted:These recent React questions certainly made me feel that way. Everything except Typescript which is pretty okay. Heh, and I see the TypeScript questions about fighting with the type system for no apparent gains and feel the same way.
|
# ¿ May 26, 2019 17:20 |
|
And no one noticed until it broke.
|
# ¿ May 27, 2019 16:57 |
|
I can’t help but feel like hooks are making this more complicated than the old way of doing it.
|
# ¿ Jun 5, 2019 02:35 |
|
Osmosisch posted:No, yarn is superior last i checked. Yeah, I’m guessing it’s just only available bundled in node and not standalone. I’m surprised yarn is available as a stand-alone download for that matter, isn’t it just another node package?
|
# ¿ Jan 26, 2020 19:27 |
|
The Dark Wind posted:Does anyone know what could possibly be causing this? Is there some sort of weird IT setting to prevent XSS or something that doesn't allow cookies to be sent through?
|
# ¿ Feb 8, 2020 15:38 |
|
Was thinking it would be neat to just have a window with a JavaScript console running all the time, rather than opening Chrome dev tools. Does that exist? I guess a terminal running node would do the job actually.
|
# ¿ Jan 13, 2021 14:41 |
|
There’s a tc39 proposal to add the set theory operators for Set: https://github.com/tc39/proposal-set-methods Page contains links to polyfills too. Sets were only added in ES6.
|
# ¿ Jan 24, 2021 01:43 |
|
If I have a POST request that seems to follow the rules for being a simple request and doesn’t trigger a CORS OPTIONS preflight, why would it still be blocked by CORS in chrome? It seems like it still wants an Access-Control-Allow-Origin header from the server, but I thought the whole point of “simple requests” was that they are backward compatible with services that predate CORS. I’m almost surely going to have to wrap this old service in a CORS supporting wrapper, so this is mainly just curiosity.
|
# ¿ Jan 29, 2021 14:14 |
|
Thanks, that makes it clearer. I spent way too long banging my head against this because I thought an existing system was making the request I wanted to make, but it turns out they were running the request from an iframe so it wasn’t cross origin.
|
# ¿ Jan 29, 2021 21:31 |
|
fireraiser posted:Given how with Next.js, you're tied into their routing and data-fetching system, it'd be pretty hard to gently caress it up in the way that you're describing. Still pretty easy to make a button that switches to another view that is not navigable to.
|
# ¿ Feb 21, 2021 16:03 |
|
It’s pretty easy to go around to big “real” websites and see how many of them just send plaintext credentials in their login forms. For instance, Chase and Citibank have no problem with it. They post username and password as form data. OTOH, Amazon does send an encrypted password.
|
# ¿ Feb 22, 2021 00:20 |
|
It does feel annoying that CORS came up around the same time that people decided that you shouldn’t host your UI and your APIs on the same server, so everything is cross-origin now. Also, the amount of time wasted by Chrome’s CORS error that suggests the “no-cors” option is surely immeasurable.
|
# ¿ Feb 25, 2021 13:56 |
|
Oops, yeah. Mixed up cause and effect.
|
# ¿ Feb 25, 2021 14:23 |
|
|
# ¿ May 10, 2024 17:03 |
|
It’s not like React is that complicated a mental model either. The render function has some inputs, some state, and an output. If you want a page that changes what it displays based on something, you just write some basic if-then code that does that.
|
# ¿ Feb 28, 2021 17:05 |