|
fsif posted:Recently collaborated with a developer that used no semicolons. It was fine. Code readability is exactly the same. semicolonless javascript is fine except when it's not. the problem is there are edge cases and they suck - like https://stackoverflow.com/questions/2846283/what-are-the-rules-for-javascripts-automatic-semicolon-insertion-asi. i don't want to have to learn these rules when people can just put the loving semicolons where they ought to go.
|
# ¿ Nov 23, 2022 15:14 |
|
|
# ¿ May 16, 2024 11:13 |
|
Doom Mathematic posted:For loops have named parts, and one of them is the "afterthought"? I had no clue. In a for loop, there are three conditions - these are referred to as initialization, condition, and afterthought. Do we know who or which standard started calling the third condition "the afterthought"? chatgpt 4 posted:It is difficult to pinpoint a specific individual or standard that started referring to the third part of a for loop as "the afterthought." The term "afterthought" is a colloquialism that has been used by some programmers to describe the third part of a for loop, which is often referred to as the "update" or "increment" statement. This term likely arose informally within the programming community as a way to describe the role of the third part in a for loop, which typically involves updating the loop control variable. That's true, it's not universally recognized. I see it on the mdn website's definition of a for loop - are there any programming language standards that refer to the "update" statement as "afterthought"? chatgpt 4 posted:After searching through various programming language documentation and standards, it appears that none of them officially refer to the "update" statement as "afterthought." MDN (Mozilla Developer Network) is a valuable resource for web developers, but it is not an official language standard. I'm seeing "afterthought" crop up on websites teaching new programmers how to use for loops, and I do see some recent stackoverflow stuff referring to afterthought, but it's not as if this name comes from any official standard.
|
# ¿ Mar 21, 2023 17:17 |
|
teen phone cutie posted:I've handwritten types by looking at the API docs at any job i've been to. i've used handwritten types in any codebase i've worked in but i did my own pilot project at work with swagger and it really saved a lot of time generating the client code with swagger codegen.
|
# ¿ Oct 2, 2023 20:33 |
|
huhu posted:Today I learned if you pass an excessively large number to setInterval in JavaScript, it'll just start executing the callback function hundreds of times a second. That took way too long to troubleshoot. https://stackoverflow.com/questions/12633405/what-is-the-maximum-delay-for-setinterval Bruegels Fuckbooks fucked around with this message at 22:08 on Oct 23, 2023 |
# ¿ Oct 23, 2023 15:35 |
|
some kinda jackal posted:Can someone explain to me, as you would a child, what a Tuple is good for? I think this is a failure of imagination because every tutorial or video I’ve seen I kind of feel like I, throwing around my entire two weeks of non-real-world programming experience, would probably use something else. One thing I see cited a lot is if I want to return multiple things from a function, at which point I instinctively just want to declare a type and have my func return that type. I guess if I don’t know exactly what I’m returning? Or is this one of those “there are eight different ways to do everything, just use whatever fits your style” type of situation? Tuple is for lazy people who don't want to make a special return value class.
|
# ¿ Nov 8, 2023 23:44 |
|
Rob Filter posted:How do you profile javascript code? Sampling seems straightforward, but I'm not sure how to do instrumental / structural profiling. Are there libraries that let you do things similarly to QueryPerformanceCounter windows stuff? the libraries that do it right are just using performance.mark() and performance.measure() https://developer.mozilla.org/en-US/docs/Web/API/Performance/mark. If you just need a current high resolution timestamp you can do performance.now(). Performance api in js is closest thing to QueryPerformanceCounter.
|
# ¿ Nov 23, 2023 07:44 |
|
smackfu posted:TIL that Typescript doesn’t follow semver, because basically every release has changes that someone would consider breaking. And 5.0 was just a major release, no more or less breaking than any other. unfortunately because ts doesn't support semver, you can't actually know whether or not a TS version will work unless you actually verify that your build works and unit tests pass with any given version of typescript. so if you're releasing a library written in typescript intended for public consumption, specifying, say, >4.7 may result in the new typescript version causing people's projects to break if they include your library. I would suggest specifying both a minimum and maximum typescript version, and only updating the maximum version when you've actually run the build with newest typescript version to verify that it actually works - e.g. process would look something like this: https://github.com/mswjs/msw/issues/1376#issuecomment-1229267340. A lot of libraries don't do this and just go with >4.7, and it does work, but past a certain size project, especially if you're using newer ts features, you're almost guaranteed SOMETHING non-obvious will break in the new typescript version, and it's much easier to figure out what went on that way rather than the completely random errors you will see from the people using bleeding edge typescript versions.
|
# ¿ Dec 24, 2023 02:24 |
|
Harriet Carker posted:I started a new job recently. The most senior frontend guy is vehemently opposed to TypeScript for reasons I don't quite understand (understanding these reasons is obviously step 1). He put up a ton of resistance when I mentioned introducing it, claiming it's too full of quirks. I don't feel like rocking the boat too much since I'm new but curious if anyone had heard any particularly convincing reasons to not use TS in a modern React app. I've been using it for about 5 years and going back to plain JS feels awful so far. I am a big typescript fan but it's a chore to take an existing js codebase, gently caress with the build process to make it compile typescript, track down definitions for all the 3rd party libraries, and actually convert it to ts so it's beneficial. That poo poo doesn't happen on its own.
|
# ¿ Jan 18, 2024 15:44 |
|
go play outside Skyler posted:As another poster said, don't use JS Date object to parse a date. It's better to use something like moment or whatever the new hotness is. don't use moment in new code. https://momentjs.com/docs/#/-project-status/ it's funny because there were all these years of "don't use raw dates, use moment", and now it's luxon. oh well.
|
# ¿ Mar 19, 2024 20:31 |
|
biznatchio posted:In general yes... until someone does new Date('September 11, 2001') with the crazy expectation that it will act the same as new Date('2001-09-11'). Date.parse in particular is hella hosed up. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse#examples Some highlights: 1. Non standard date strings were allowed to be implementation specific, so there's no guarantee they work the same between any browser. 2. There's no parameter for the expected format of the date string, or region of the date string, so it's up to the browser implementation to guess from the content of the string which date format it is - which is great when it tries to parse a string like 9-11-2001, which could easily parse as December 9, 2001 in some parts of the world.
|
# ¿ Mar 20, 2024 15:11 |
|
|
# ¿ May 16, 2024 11:13 |
|
Combat Pretzel posted:I am returning undefined nilly-willy in all my projects whenever something's not found or available.
|
# ¿ May 12, 2024 15:54 |