|
Dominoes posted:New JS versions already compile down to existing JS; just have the transpiler interpret array1 == array2 as whatever verbose syntax you currently need to use. Code bases that rely on the current comparison behavior can skip the new language/transpiler. This is much better handled by using a library function call. You don't want to fundamentally change the existing language semantics. What if I WANT to check for reference equality?
|
# ? Jun 19, 2017 02:52 |
|
|
# ? Jun 5, 2024 06:01 |
|
And knowing it's an array at compile time is practically impossible without something like typescript.
|
# ? Jun 19, 2017 04:10 |
|
All the talk about comparing arrays completely glosses over that this program does not in any sense need to ever compare two arrays together, since you're basically doing a modified Gaussian sumcode:
Vulture Culture fucked around with this message at 07:05 on Jun 19, 2017 |
# ? Jun 19, 2017 06:50 |
|
Maluco Marinero posted:basic facts about JavaScript equality and how to rigorously test it properly. Please elaborate what you mean by this.
|
# ? Jun 19, 2017 08:00 |
|
I'm a lodash programmer who dabbles in vanilla javascript occasionally. How I would answer in an interview test:code:
|
# ? Jun 19, 2017 11:30 |
|
What's recommended to track js memory heaps and such? I tend to rely on chrome tools, but is there some other way?
|
# ? Jun 19, 2017 13:01 |
|
Dominoes posted:JS is an evolving language; no excuse for comparing the arrays directly not to work. Deep comparing of arrays by default isn't how C# et al work either.
|
# ? Jun 19, 2017 14:01 |
|
Maluco Marinero posted:How do you propose to implement that without breaking all the code that depends on referential checks for high performance? Quadruple equals for deep equality with coercion and quintuple equals for deep non-coercing equality
|
# ? Jun 19, 2017 15:44 |
|
Munkeymon posted:Quadruple equals for deep equality with coercion and quintuple equals for deep non-coercing equality YOU'VE DONE IT NOW!
|
# ? Jun 19, 2017 21:24 |
|
Skandranon posted:YOU'VE DONE IT NOW! We're going to need a new Boolean type that carries information on which type of equality was used to derive the value.
|
# ? Jun 20, 2017 17:23 |
|
Lumpy posted:We're going to need a new Boolean type that carries information on which type of equality was used to derive the value.
|
# ? Jun 20, 2017 17:26 |
|
Ghost of Reagan Past posted:I propose we adopt the four Boolean values of LP: true, false, both, and neither. Don't forget FILE_NOT_FOUND
|
# ? Jun 20, 2017 17:49 |
|
Just had a recruiter start a phone screening by asking me what this does:code:
I think I'm gonna pass on this one. (Other questions I hosed up: what's the difference between an Int and a Float, and if Ints are just part of the set of Floats, why not use a Float for everything? Also, quick, what's the regex for extracting phone numbers from 10000 HTML files off the top of your head?) Pollyanna fucked around with this message at 21:00 on Jun 20, 2017 |
# ? Jun 20, 2017 20:57 |
|
Pollyanna posted:Also, quick, what's the regex for extracting phone numbers from 10000 HTML files off the top of your head?) code:
|
# ? Jun 20, 2017 21:19 |
|
Pollyanna posted:Just had a recruiter start a phone screening by asking me what this does: God I hate when recruiters ask questions on the phone. Like before I knew was lazy loading was, I was asked what it was over the phone and was like "uhh idk, but I'm sure I could google it and tell you"
|
# ? Jun 20, 2017 22:41 |
|
Pollyanna posted:Just had a recruiter start a phone screening by asking me what this does: In what ungodly universe would that actually appear in any reasonable kind of code? I spent some time with it in JSBin, apparently ('two'<'three') evaluates to false, then the '+' converts it to a 0, which accesses 'repeat' from the preceding array, so you end up calling '123'.repeat(3). No way in hell could I have figured that out without some tinkering first though. edit: How about code:
|
# ? Jun 20, 2017 23:46 |
|
That will miss a bunch of variations. Asking that over the phone (or ever really) is pretty bad though.
|
# ? Jun 21, 2017 00:01 |
|
Because I had some free time this afternoon:code:
Took about 20 minutes playing with regex101. I'm bad at regexes
|
# ? Jun 21, 2017 00:09 |
necrotic posted:That will miss a bunch of variations. Asking that over the phone (or ever really) is pretty bad though. How do you even reply to that kind of question over the phone? "SURE, THE ANSWER IS SLASH D OPEN CURLY BRACE THREE CLOSE CURLY BRACE DASH..."
|
|
# ? Jun 21, 2017 00:15 |
|
The Dark Wind posted:In what ungodly universe would that actually appear in any reasonable kind of code? I spent some time with it in JSBin, apparently ('two'<'three') evaluates to false, then the '+' converts it to a 0, which accesses 'repeat' from the preceding array, so you end up calling '123'.repeat(3). No way in hell could I have figured that out without some tinkering first though. That's also assuming it's JavaScript, which was not obvious as ES5 does not have a string.repeat(), ES6 does. So this is some stupid puzzle adapted from 10+ years ago and the guy was lying about it coming from production code, or he is sitting on one of the biggest code-bombs ever, and it's being actively developed with modern technology. I could at least excuse it (not really) if it came from some legacy system that they are afraid of and trying to deconstruct, but this... How the hell do you find these people Poly?
|
# ? Jun 21, 2017 00:24 |
|
I like to imagine they implemented their own repeat 10 years ago and put it on the String prototype.
|
# ? Jun 21, 2017 00:29 |
|
Skandranon posted:That's also assuming it's JavaScript, which was not obvious as ES5 does not have a string.repeat(), ES6 does. So this is some stupid puzzle adapted from 10+ years ago and the guy was lying about it coming from production code, or he is sitting on one of the biggest code-bombs ever, and it's being actively developed with modern technology. I could at least excuse it (not really) if it came from some legacy system that they are afraid of and trying to deconstruct, but this... How the hell do you find these people Poly? His exact words were "this is something you can expect to encounter in our code base", which I took to mean "this is what you're gonna be working with". Maybe I misunderstood. Also, I have weird luck and I apply to lots of places on AngelList. This one was a throwaway where my note to them was "Do you do cats?".
|
# ? Jun 21, 2017 01:01 |
|
Pollyanna posted:Just had a recruiter start a phone screening by asking me what this does: The correct answer is, "Who ever wrote that should be defenestrated immediately."
|
# ? Jun 21, 2017 01:05 |
|
Pollyanna posted:His exact words were "this is something you can expect to encounter in our code base", which I took to mean "this is what you're gonna be working with". Maybe I misunderstood. lol. geeves posted:The correct answer is, "Who ever wrote that should be defenestrated immediately." Yeah, it's this or, "I could reduce this down to an answer but we need to address the fact that production code looks like this before I can continue caring about this interview."
|
# ? Jun 21, 2017 01:23 |
|
geeves posted:The correct answer is, "Who ever wrote that should be defenestrated immediately." Or just: "so you need a new team lead then?"
|
# ? Jun 21, 2017 02:19 |
|
The Fool posted:Because I had some free time this afternoon: This was actually a lot of fun, haven't done this in a bit but could have probably aced the phone interview. code:
e: I'm incompetent and only matched all numbers. I'll just see myself out. Video Nasty fucked around with this message at 03:13 on Jun 21, 2017 |
# ? Jun 21, 2017 03:09 |
|
Video Nasty posted:e: I'm incompetent and only matched all numbers. I'll just see myself out. It's okay, we're just trying to get a sense of how you think
|
# ? Jun 21, 2017 05:24 |
|
Moment's API is making me a little and I want to run something by you guys because I'm getting the right answer but don't fully understand/haven't realized yet why. I have a local date+time and I'm getting a UTC offset from a weather API. I'm trying to reliably get moment to spit out an epoch time that corresponds to that location's time instead of device location. This gives me the right answer:JavaScript code:
Yes, I know there's a time zone library, but I'm hoping to avoid pulling in a whole 'nother library for this one line since this is mobile-centric thing. E: at least I think this is right - could just be plugging the wrong times into epochconverter Munkeymon fucked around with this message at 16:19 on Jun 21, 2017 |
# ? Jun 21, 2017 16:01 |
|
Pollyanna posted:Just had a recruiter start a phone screening by asking me what this does: It's probably a bad sign fro my mental health that I figured out what it did without running it, but I did have to pick it apart in the debugger to confirm what I was thinking. The only reason something like that should ever come up is if you've got a requirement to find people who can debug minified JS for some reason.
|
# ? Jun 21, 2017 16:07 |
|
I mean, I understood what it was trying to do once I stared at it for a bit, but my brain kind of shut off automatically as a safety procedure when I first saw it.
|
# ? Jun 21, 2017 16:19 |
|
I need a callback when a web font is loaded, but I can't find any cross browser solution. Font loading is a problem when using a web font on canvas. I'm using jquery fontselect to select a Google web font from a drop down. The font selection drop down doesn't actually guarantee the font will be ready in time for the text to rendered on canvas. I can prove this by selecting a font from the drop down before the correct font face is visible in the preview. Text using web fonts before they are loaded appear to show up as Times New Roman. This is unlike using a web font on other elements that redraw themselves as the correct font by the time they are loaded. The conundrum of this problem is that there appears to be no cross browser solution to loading web fonts. If I could properly get a callback on all browsers, this wouldn't be a problem.
|
# ? Jun 21, 2017 19:57 |
|
You should be able to use the load event unless you have to target older browsers. With jQuery you could listen for load on all existing and future link tags with:code:
|
# ? Jun 21, 2017 21:36 |
|
It looks like Google's Webfont Loader looks to be way more promising than I thought, mostly because I can't see of it being documented anywhere that you can place the event handler in Webfont.load except for one Stack Overflow post I came across THANK GOD. I can call WebFont.load inside a function, and then render my canvas when the font is ready to be rendered on screen: code:
|
# ? Jun 21, 2017 21:45 |
|
The configuration section of the readme says explicitly that the config options listed can go into the load call. In the very first sentence of that section.
|
# ? Jun 22, 2017 01:11 |
|
necrotic posted:The configuration section of the readme says explicitly that the config options listed can go into the load call. In the very first sentence of that section. You're right, but good documentation would actually show an example of it happening.
|
# ? Jun 22, 2017 16:15 |
|
Wasn't somebody in here starting an immutable date library? Is this you: https://js-joda.github.io/js-joda/ ??
|
# ? Jun 23, 2017 20:02 |
|
It's this guy.Dominoes posted:Hey dudes. Looking for API feedback on the datetime module I've been working on. And a re-attack on why I can't get it to import as an npm module (But can by placing the source file in the same folder as my project). I've decided to de-couple it from DateFns, since I'm unable to get around it not accepting these custom types as valid when using certain funcs, as well as API limitations I hadn't noticed with it earlier. (ie it's impossible to safely turn a string into a date with that module).
|
# ? Jun 24, 2017 01:53 |
|
Also gently caress yes a joda clone. Edit by the author of joda even. Finally, a not poo poo date lib for js. No offense dominoes, it's a hard problem.
|
# ? Jun 24, 2017 01:54 |
|
Yep, twas me... And that library looks exactly like what I was trying to build... to the point where it means I should abandon the project, despite the basics being done. Date-fns was a false-messiah, but this may be the real deal.
|
# ? Jun 24, 2017 02:31 |
|
|
# ? Jun 5, 2024 06:01 |
|
necrotic posted:Also gently caress yes a joda clone. Joda Time was a godsend pre-Java 8, so it's nice to see that JsJoda exists. Wish I had known about it sooner. Moment is decent, but its API is just weird. A more Java-like implementation is most welcome. And may be something to which I can actually contribute.
|
# ? Jun 24, 2017 02:44 |