Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds a couple of ES6 related questions (partly addresses #421) #440

Merged
merged 1 commit into from Jan 18, 2018

Conversation

Powell-v2
Copy link
Contributor

@Powell-v2 Powell-v2 commented Jan 17, 2018

Here is an addition to JS section: 4 questions about latest ES6 standard.

1. What is the most modern approach to accessing the list of arguments passed to a function?

This question identifies if candidate is aware of rest syntax, which is the modern standard for handling parameters passed to a function. Explaining what is the problem with arguments, imo, should count as bonus points.

2. What are the benefits of using spread syntax and how is it different from rest syntax?

If a candidate knows in which cases to opt for spread syntax, it means that he/she is writing more concise, cleaner code (e.g. replacing apply). Knowing the difference is really important since both syntaxes look exactly the same, but the aims are different.

3. How can you share code between files?

This one tests candidate's knowledge about ES6 modules, which is an essential part of modern day web development.

4. Why you might want to create static class members?

The purpose is to elicit an explanation of "static vs. private", plus common use case for static class methods.

@blackfalcon
Copy link
Contributor

These are great questions. Especially the one about spread vs rest syntax. I have always felt a little gross when considering using the apply() method to pass in an array to a function. 👍

That being said, I am wondering if the preceding question What is the most modern approach to accessing the list of arguments passed to a function? is really necessary? What is the most modern approach while these methods are new with ES6, that statement is pretty opinionated. I'd argue that by simply asking the question specifically about the spread versus rest syntax you are already asking the first question.

@Powell-v2
Copy link
Contributor Author

You have a valid point : )

However rest operator improves on arguments - no need to convert, already a fully-fledged array. The idea is that 2nd question build on the 1st one. And as you pointed out, most modern refers to the latest method that became available - how is this opinionated?

Anyway, could be rephrased or completely removed, up to you : )

@blackfalcon
Copy link
Contributor

@Powell-v2 my reference to most modern being an opinion as this is not an official statement of the specification. It is an opinionated statement that this is a modern technique, of which I don't disagree, but in the vein of giving questions the longest lifespan possible, I suggest not stating it that way.

In short, will this still be the most modern solution in 3 years?

@Powell-v2
Copy link
Contributor Author

In short, will this still be the most modern solution in 3 years?

Probably not, who knows.

How about rephrasing: "What is the latest standard for accessing the list of arguments passed to a function and how it compares to other approaches?"

@blackfalcon
Copy link
Contributor

I guess, as an interviewer, I would never ask that question as there is too much room for debate. Again, I assume that this is in reference to the spread syntax versus using the apply() hack?

I guess I have a personal preference for more direct questions as not to let the interviewee flail.

 What are the benefits of using spread syntax and how is it different from rest syntax?

Great question. Maybe something along this line of questioning that reveals the dev's knowledge of passing in an array to a function.

@Powell-v2
Copy link
Contributor Author

Powell-v2 commented Jan 18, 2018

I assume that this is in reference to the spread syntax versus using the apply() hack?

What I had in mind was the 'rest syntax' which eliminates the need to convert arguments object into array:

function f(a, b) {
  let args = Array.prototype.slice.call(arguments);
  // or
  let _args = Array.from(arguments);
}

vs.

function f(...args) {
  // no need for conversion, args variable is ready for slicing and dicing 
}

@blackfalcon
Copy link
Contributor

Right. I had assumed that you were referencing the spread side of the story, not the rest side. This is where I feel clearer questions help everyone.

@Powell-v2
Copy link
Contributor Author

Indeed. I'm glad we discussed this : ) Commit has been updated - I removed 1st question.

@roblarsen roblarsen merged commit 4366366 into h5bp:master Jan 18, 2018
@roblarsen
Copy link
Member

🥇

@Powell-v2 Powell-v2 deleted the pr/add-ES6-questions branch January 18, 2018 18:33
musmanraodev added a commit to musmanraodev/Front-end-Developer-Interview-Questions that referenced this pull request May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants