Test Your JavaScript Knowledge - JavaScript/ES6 Interview Questions and Answers
Some minor comments:
Q2: "Local scope can be local to a function or a block." Or module - another local scope
Q2: "Variables defined using var have function scope."/"Variables and constants defined using let and const have block scope." Unless used in the global scope, at which point they're global
Q2: "In case of a block scoped variable, its value is inaccessible before its first assignment." More accurately, its before the location of the declaration. You can declare a variable with
letwithout defining it and still be able to access it prior to its first assignment.let x;
console.log(x); // Ok, = undefined
x = 1; // first assignmentQ3: "JavaScript functions have prototypes." Not all functions. Arrow functions and methods do not.
() => {} // no prototype
{ foo(){} } // foo: no prototype
class { foo(){} } // foo: no prototypeQ5 (and Q4): No use of super.deposit()?
Q6: "In JavaScript,
thisis a function scoped variable." It also exists in global.Q6: "Under normal circumstances,
thisrefers to the object owning the function." Specifically, the function call, not the function itself.this, under those normal circumstances, is determined dynamically at call time and applies to the call itself rather than the function object.Q6: "In global functions,
thisequals the global scope." Only if its being called from the global object, otherwise itsundefined(given that it was mentioned earlier, "this test is in strict mode").Q8: "When using the global symbol registry, we get the exact same symbol belonging to the string
'a', whenever we callSymbol.for( 'a' )." This feels a little out of place without first mentioning how symbols are inherently unique.Q9: "A correct check [to see if a value is an Array] is the usage of the
instanceofoperator:" This is a way to check, but its less correct than the best solution ofArray.isArray... though still more correct than comparing theconstructor. Actually thetypeofchecks below might be better since it works across multiple globals. WithoutisArray, its often suggested instead to useObject.prototype.toStringand compare to"[object Array]"since it would work in most cases, though even this approach can be interfered with usingtoStringTag. At any rate, I think the usage of "correct" should fall toisArrayand notinstanceof.
JavaScript programming interview questions?
How was your JavaScript interview this 2018?
Senior role interview probably vary a lot more than a typical mid-level interview, since from my experience there's a different meaning to 'Senior' everywhere. Some places it's more of a managerial role, others its more of a technical knowledge role. Nevertheless last time I interview it was for a place that also uses primarily React and Node. Here's a general gist of what I was asked for a mid-level Front-end interview with some Node added since I would be expected to write some of that as well:
A lot of basic to intermediate js questions. Things like context/
thisin Javascript. Prototype knowledge, inheritance model, asynchronous behavior (callbacks, promises, async/await, a little bit of generators but only because I mentioned it), the event loop/callback queueReact specific questions revolved around patterns like Higher order Components, Render Props/Function as child, why use React in the first place? Comparison to past popular frameworks as well as current ones (since I was coming from a place that used Vue), JSX vs templates, asking about past projects, etc.
Node questions revolved around more of the event loop, general http questions, a little graphQL (i had never used it but heard of it), some specific framework knowledge around express/koa (they don't use express).
I was interviewing for more of a Front-end focused role, but expected some Node stuff anyway. Not as much around Node was asked, but a lot around general JS stuff. So the interview also consisted of a lot of knowledge around CSS, general layout best practices (semantic html), performance in the browser, etc.
More on reddit.comBest List of Frontend JavaScript Interview Questions (by a Frontend Engineer)
I am not a fan of questions that ask CS fundamentals. I have never had to implement BinarySearchTree as part of my job. It has no value and doesn't indicate anything about the candidate being able to perform his/her job except remembering what they did in college
The best question on this is:
My website is slow. Walk me through diagnosing and fixing it. What are some performance optimizations people use, and when should they be used?
Otherwise not sure the value of memorizing how to implement quickSort or MergeSort will help you be a valued front-end member of the team.
What I would prefer to see as questions asked:
Can you explain how eventing works in node / JS?
Can you build an event emitter?
Can you explain the difference between declarative programming vs. imperative programming? Can you give an example?
I have an error in this code sample.. can you go through and fix the problem? How would you approach fixing the problem? What tools would you use?
How would you refactor this code piece? What are some code smells? What would you do about testing?
If you are hitting an API and all of a sudden you get an error. What do you do? What if the errorcode is a 500? 404? 429?
JavaScript has class syntax from es6 onward. Why would you use it? What is JS compiler actually doing when you write a class syntax? What is prototypical inheritance? What write methods on the prototype?
CSS questions? Flexbox? Grid? Box Model? BEM?