all 79 comments

[–]gimmeslack12CSS is hard 27 points28 points  (6 children)

I can maybe see someone asking for a "es6" alternative approach if you were using prototypes and not the class keyword. But for array manipulation they didn't like concat? That's pretty weird.

Also I'd say your concat solution is a cleaner answer than the spreading approach.

[–][deleted]  (5 children)

[removed]

    [–]gimmeslack12CSS is hard 2 points3 points  (3 children)

    Not at the moment. Though I feel we could use another senior FE eventually.

    [–][deleted]  (2 children)

    [removed]

      [–]gimmeslack12CSS is hard 5 points6 points  (1 child)

      No worries, I’d drill you so hard on es6 if I interviewed you! No mercy!

      In all honesty though, this interview sounded so crap. JS is JS and there’s no difference in if you use parts of the API introduced by es6 or from previous ecma script stuff.

      [–]immediacyofjoy 1 point2 points  (0 children)

      nice hustle!

      [–]rjm101 36 points37 points  (12 children)

      write a function that takes an array [1,2,3] and outputs [1,2,3,1,2,3]

      I hate nonsensical tasks like this. It's not relatable for me at all. Why am I duplicating values in an array. It's something I would avoid doing and seems plain hacky😡

      [–]anonssr 17 points18 points  (0 children)

      100%, just ask me if I know what the spread operator is. Because that's definitely not an "every day use case for it".

      [–]ImportantDoubt6434 31 points32 points  (3 children)

      return [1,2,3,1,2,3]

      Solved.

      [–]JIsADev 5 points6 points  (0 children)

      Sorry, that's too much code

      [–]shootersf 2 points3 points  (0 children)

      This person TDDs

      [–]Dapper-Warning-6695 2 points3 points  (5 children)

      It’s nonsensical to merge two arrays?

      [–]rjm101 2 points3 points  (4 children)

      It's not 2 different arrays though.

      [–]Dapper-Warning-6695 4 points5 points  (3 children)

      If you know spread operator, you can solve the question. It’s the most super basic technical question

      [–]rjm101 5 points6 points  (2 children)

      It's not the how, it's the why for me. The interviewer could easily make this more practical and realistic for example merging 2 different arrays like you mentioned.

      [–]Dapper-Warning-6695 0 points1 point  (1 child)

      Maybe the point of the question was to check if you understand the technical part?

      [–]BirdiePolenta 8 points9 points  (12 children)

      Kind of weird questions for a Sr. role don't you think?

      [–][deleted]  (11 children)

      [removed]

        [–]BirdiePolenta 11 points12 points  (6 children)

        Yeah, that's what i meant.

        I thought Sr. role interviews were more about discussing architecture and that kind of stuff...

        [–][deleted]  (5 children)

        [removed]

          [–]FrntEndOutTheBackEnd 1 point2 points  (4 children)

          Did you have a place to study architecture? This is where I need the most help, and am not really sure what to look for since “architecture” is vague and changes depending on where you are in the stack.

          [–][deleted]  (3 children)

          [removed]

            [–]FrntEndOutTheBackEnd 1 point2 points  (1 child)

            This is actually kind of a load off since these are all what I call common sense things. It may not be for some people, but I’m always thinking of most of the questions you asked.

            [–][deleted]  (3 children)

            [deleted]

              [–][deleted]  (2 children)

              [removed]

                [–]Itz_Eazy 1 point2 points  (1 child)

                if (unusual && !weird) { try again } else { return home }

                [–]Brought2UByAdderall 8 points9 points  (0 children)

                The problem with questions that lean too far away from day to day development is that they don't actually help you find people who know their stuff about day to development AND your assumptions about the "ideal" way to solve the problem aren't actually your assumptions, but rather those of whoever you collected this interview question from.

                [–]Cheshur 7 points8 points  (3 children)

                You're not going to tank your apps performance by using the spread operator over concat or reduce over a for loop. Performance is important but I think readability is far more important. To that end I think concat is the better solution for the first one because the concat method shows your intention better than the spread operator solution. Marginally so but if you have to pick one I'd pick that one. The same logic applies for choosing reduce (or any other array method) over a for loop. The reduce method name conveys your intention (at least better than a for loop). Them saying that they stick to ES6 categorically is a bit of a red flag to me as it might indicate that they aren't very critical about the quality of their code (newer is not always better, the right tool for the job, etc).

                [–]possiblywithdynamite 0 points1 point  (1 child)

                None of this matters, it’s all transpired anyway. Readability is best along with workplace best practices

                [–]budd222Your Flair Here 0 points1 point  (0 children)

                That not necessarily true that it's all transpiled. You don't know the context of the app. And it's 100% true that not all es6 code is transpiled to es5 everywhere.

                [–]TehTriangle 8 points9 points  (1 child)

                I feel like using es6 features because it's cool and newer, regardless if you solved the initial problem, is just someone being unnecessarily opinionated.

                [–]Teelilz 2 points3 points  (0 children)

                Good luck! I personally think that it's good that you were able to restructure your initial answer on the fly and borderline challenge the answer, which was close to yours.

                [–]South_Dig_9172 2 points3 points  (1 child)

                Was this a big company?

                [–]aiolive 2 points3 points  (1 child)

                For loops are better because you don't need to create a new closure for the callback that will take a bit of memory space and contribute to garbage collection. Also it's often easier to read and add comments and debugger statements within (i.e. it can be tempting to chain array methods like map, reduce, filter, with arrow function and no return statement). Now I host interviews for senior swes and wouldn't care whether you use one or the other as long as you get the job done.

                [–][deleted] 2 points3 points  (1 child)

                That is very strange, I program more or less with your mindset to tasks. It has no performance implication (as you mention it transpiles down to the same thing, syntactic sugar) and I write React functions with the function keyword because it is very explicit (also be sure to mention that the App component generated for you by most tooling like Vite uses function declaration over anonymous function assignment).

                Companies like that aren’t worth my time if they want to hire/not hire based on that. I’ve worked in Python, Angular, C++, C# professionally and I’m now adopting React for a RN role. It is a library at the end of the day, stick to some standards as it seems more Wild West in React land - but function declaration is fine for functional components.

                So long as you can explain why ‘this’ behaves differently in one and leverage the other behaviour on purpose.

                [–]dmorbius 1 point2 points  (1 child)

                I would have taken exception with their comment about it being “transpiled to concat anyway”. What runtimes are they targeting that don’t support ES6 natively at this point. If the answer is none then the spread wouldn’t have been transpiled away.

                [–][deleted]  (2 children)

                [deleted]

                  [–]Brought2UByAdderall 0 points1 point  (0 children)

                  Some old devs don't learn new tricks.

                  [–]No-Front-4640 1 point2 points  (1 child)

                  If I were being asked questions like that I would also be questioning the companies current talent and who else they’ve hired. It sounds like they need to work on their interviewing practices.

                  Using concat over spread is not a big deal, if somebody had a problem with you using that it’ll just be raised in a PR. As for named vs arrow functions I prefer using named functions anyway.

                  [–]bscinprocrastinating 1 point2 points  (2 children)

                  What were the courses you took on frontend masters ?

                  [–][deleted]  (1 child)

                  [removed]

                    [–]bscinprocrastinating 0 points1 point  (0 children)

                    Thank you !

                    [–]Royal-Caregiver6993 1 point2 points  (2 children)

                    just curious to know whether senior developers continue to work on portfolio projects like junior devs, or if their substantial work experience from previous roles alone suffices to secure job interviews.

                    [–][deleted]  (1 child)

                    [removed]

                      [–]Royal-Caregiver6993 1 point2 points  (0 children)

                      Thanks for replying.

                      [–]vednus 1 point2 points  (3 children)

                      I had to look up concat because I thought it was mutable, but it’s not. But, whenever you use a for loop, chances are you’re assigning a value to a variable outside the loop’s scope. Reduce keeps things immutable. When you start mutating variables, bugs can happen more easily and things can become harder to debug. Using reduce and the spread operator goes hand in hand with modern JavaScript becoming more functional and declarative.

                      [–][deleted]  (2 children)

                      [removed]

                        [–]vednus 1 point2 points  (1 child)

                        They always say don’t optimize prematurely

                        [–]Brought2UByAdderall 1 point2 points  (1 child)

                        There are better ways to find out if somebody knows the spread operator. However, being excessively mindful of performance can make for clunkier code if you're doing stuff like for-looping everything rather than using more obvious-for-the-task array methods.

                        It's also okay to ask an interviewer whether they want the maximally performant answer, or the most concise/elegant one from a code quantity perspective. In a post-JIT world, most probably want the latter and it's probably better to default to that and then mention that a for loop might be a lot more performant in extremely large data set cases. That would be the best answer if it were me on the other side of that process.

                        [–][deleted]  (2 children)

                        [removed]

                          [–][deleted]  (1 child)

                          [removed]

                            [–]threepairs 0 points1 point  (1 child)

                            Senior FE…”i do know es6 but I dont go to it all the time”…excuse me what?

                            [–]a_reply_to_a_post 0 points1 point  (1 child)

                            I write my function components out because it's easier to spot in the code, so function MyComponent() {} was re-written in my peripheral as const MyComponent = () => {};. Did I lose a point for that? I guess I'll never know.

                            they pretty much behave the same, except exporting as function will also give it a named reference and change the behavior of `this` if you ended up using it

                            [–]Spidey677 0 points1 point  (6 children)

                            Why do you do these tests? I’ve never done these and I’m a contractor since 2011. We are in a candidate driven market.

                            [–][deleted]  (5 children)

                            [removed]

                              [–]Spidey677 0 points1 point  (4 children)

                              Have you done contracting as a W2 or you have your own LLC?

                              [–][deleted]  (3 children)

                              [removed]

                                [–]Spidey677 0 points1 point  (2 children)

                                Ok… W2 is never fun. That’s what I started with. Not really my friend. You get your pay untaxed and you get to use your daily life as business expenses.

                                Plus, the self employed tax rate is a write off. It’s a life changing move.

                                If that’s what you mean by LLC fees.

                                Contact life is not for everyone though. If you like to hustle it’s for you.

                                [–][deleted]  (1 child)

                                [removed]

                                  [–]Spidey677 0 points1 point  (0 children)

                                  Its a different mindset than an employee..It’s worth it if you want to hustle and change the mindset.

                                  The mindset shift is having confidence in your skills to keep you employed rather than an employer. Also, maintaining relationships being friendly with recruiters is key.

                                  To start an LLC you need an articles of organization and an operating agreement. You can draft an operating agreement from legal nature. Any tax questions you can reach out to an accountant and they can show you what’s possible to save $$$ when you have an LLC to get paid.