Pro JavaScript programmer interview questions (with answers) [closed] - javascript

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
What are good questions to determine if applicant is really a pro JavaScript (browser side) developer ?
Questions that can distinguish if someone is not an ad-hoc JavaScript programmer, but is really doing professional JavaScript development, object-oriented, reusable, and maintainable.
Please provide answers, so an intermediate and ad-hoc JavaScript programmers can interview someone more experienced, coming up with answers to quite few of those advanced questions will elude me. Please avoid open questions.
Please keep one interview question/answer per SO answer for better reading experience and easier interview preparation.

Because JavaScript is such a small language, yet with incredible complexity, you should be able to ask relatively basic questions and find out if they are really that good based on their answers. For instance, my standard first question to gauge the rest of the interview is:
In JavaScript, what is the difference between var x = 1 and x = 1? Answer in as much or as little detail as you feel comfortable.
Novice JS programmers might have a basic answer about locals vs globals. Intermediate JS guys should definitely have that answer, and should probably mention function-level scope. Anyone calling themselves an "advanced" JS programmer should be prepared to talk about locals, implied globals, the window object, function-scope, declaration hoisting, and scope chains. Furthermore, I'd love to hear about [[DontDelete]], hoisting precedence (parameters vs var vs function), and undefined.
Another good question is to ask them to write a sum() function that accepts any number of arguments, and returns their sum. Then, ask them to use that function (without modification) to sum all the values in an array. They should write a function that looks like this:
function sum() {
var i, l, result = 0;
for (i = 0, l = arguments.length; i < l; i++) {
result += arguments[i];
}
return result;
}
sum(1,2,3); // 6
And they should invoke it on your array like this (context for apply can be whatever, I usually use null in that case):
var data = [1,2,3];
sum.apply(null, data); // 6
If they've got those answers, they probably know their JavaScript. You should then proceed to asking them about non-JS specific stuff like testing, workflows, version control, etc. to find out if they're a good programmer.

Basic JS programmming
Scope of variable
What is Associative Array? How do we use it?
OOPS JS
Difference between Classic Inheritance and Prototypical Inheritance
What is difference between private variable, public variable and static variable? How we achieve this in JS?
How to add/remove properties to object in run time?
How to achieve inheritance ?
How to extend built-in objects?
Why extending array is bad idea?
DOM and JS
Difference between browser detection and feature detection
DOM Event Propagation
Event Delegation
Event bubbling V/s Event Capturing
Misc
Graceful Degradation V/s Progressive Enhancement

Ask about "this". This is one good question which can be true test of JavaScript developer.

(I'm assuming you mean browser-side JavaScript)
Ask him why, despite his infinite knowledge of JavaScript, it is still a good idea to use existing frameworks such as jQuery, Mootools, Prototype, etc.
Answer:
Good coders code, great coders reuse. Thousands of man hours have been poured into these libraries to abstract DOM capabilities away from browser specific implementations. There's no reason to go through all of the different browser DOM headaches yourself just to reinvent the fixes.

Ask them how they ensure their pages continue to be usable when the user has JavaScript turned off or JavaScript isn't available.
There's no One True Answer, but you're fishing for an answer talking about some strategies for Progressive Enhancement.
Progressive Enhancement consists of
the following core principles:
basic content should be accessible to all browsers
basic functionality should be accessible to all browsers
sparse, semantic markup contains all content
enhanced layout is provided by externally linked CSS
enhanced behavior is provided by [[Unobtrusive
JavaScript|unobtrusive]], externally
linked JavaScript
end user browser preferences are respected

Ask how accidental closures might cause memory leaks in IE.

Ask "What unit testing framework do you use? and why?"
You can decide if actually using a testing framework is really necessary, but the conversation might tell you a lot about how expert the person is.

intermediate programmers should have technical mastery of their tools.
if he's passed the technical phone screen-esque questions above, make him sketch out something stupid on the spot, like an ajax url shortner. then grill him on his portfolio. no amazing portfolio = intermediate developer in this domain and not the guy you want in charge of your shiny new project.

Related

jQuery resource for Win32 programmer [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I know programming in general but always been doing either Delphi, VB 6 or C#.net! Now I must do web-dev and must do it fast! I haven't written a hello world in JavaScript yet and must learn jQuery because there are some charts that I must show in my web-app and looks like I must know JavaScript and jQuery to do that.
So I am looking for a jQuery resource that during its course or maybe at the first chapter gives us also a jump start on minimum JavaScript knowledge too. Some book or resource that I can hopefully sit and read through it in one day like 12 hours and after then learn enough to be able to use it and embed those darn charts and graphs into my web-app.
What do you suggest ?
The basics of Javascript as a language are actually fairly straightforward, particularly if you've got a background in several other languages as you have. You'll find it immediately familiar with curly braces and other syntax that you'll recognise from elsewhere.
If you've worked with C#, you will hopefully have been exposed to lambda functions or closures. These are very important in Javascript, where they are key for the event-driven code that drives most websites, and in particular if you're using a library like jQuery, where they are used for virtually everything. You need to get a strong handle on how these functions work if you're going to make head or tail of jQuery.
The other thing to be aware of is that Javascript's object handling works a bit differently to the other languages you's used to. There are similarities, but if you try to write your classes and objects in the way you're used to, you will get some unexpected results. See What type of language is JavaScript for more info on this.
Beyond that, I don't think you'll have a problem with the syntax.
The other thing to worry about is the DOM -- ie the browser's API which is accessed via Javascript. The DOM is not technically part of the Javascript language, but it is inextricably linked to it, and is as much part of the learning challenge as the language itself. jQuery abstracts a fair amount of the DOM away from you, but it still helps to know it.
Hope that helps get you started.

Is Backbone better choice for beginners than AngularJS? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
The last couple of years I've spent working in Flex. Before that I've been building web applications in vanilla JavaScript.
Today I'm switching back to JavaScript but now I'm having trouble in choosing the right JS framework/library for a new medium-size project.
Although all the comments on AngularJS have been positive, I found that getting started with it is not an easy task. The problem is of course the documentation. Although there are tutorials which show you how to do the basic stuff, none explain the concepts or show you how one might structure larger projects.
Before discovering AngularJS I had my mind set at Backbone. The positive side is that there are loads of documentation, tutorials, screencasts, books on the subject. In addition the source code is small and can be used as a reference itself (unlike AngularJS).
So now I'm thinking that Backbone might a better choice for someone who's getting stared with using frameworks in JS programming than AngularJS. Later on, when I manage to train my brain to think in JS, AngularJS might be easier to understand + there will be more documentation available.
I'm now in doubt if that's the right path to choose...
First of all, I'm pretty sure that switching to JavaScript was the right choice.
Selecting a JavaScript MVC framework is indeed a difficult choice, especially because they're popping like popcorns everywhere!
This project might be very helpful regarding this decision: http://addyosmani.github.com/todomvc/
Here is my point of view. Backbone is liberal. It does not impose a rigid structure. It is more a set of conventions than actual code. You will certainly be using something more than just the Backbone framework. This can be challenging, but may result in a better tuned result. Backbone is very extensible by nature, which is a great advantage.
AngularJS augments HTML semantics. Just by saying this you can imagine that it is something much more complex than just "pure" Backbone. Perhaps we may find AngularJS a bit more magical (not magical of course, but things happening with less code, "under the hood", I mean).
They have very different approaches to the problem.
I'm not going to state here every advantage and disadvantage of each one. The link I posted should help you on that.
I too was confused like you, but in short, investigate both, make some spike implementations with both, and check the todoMVC project. Choose wichever suits better your requirements and even personality. :)
A much more fairer comparison could be "Backbone and friends" vs "AngularJS". Don't forget Backbone's friends (plugins and modules).
You can do great things with both.
I've been there past few days. I've implemented a simple CRUD over REST api in both frameworks. Here are my thoughs:
Angular is harder, because it's convention over configuration, new concepts like directives and such, you need to think with extending HTML instead of javascript hacking (which can be not that difficult for flex practitioners).
But in the end I prefer it because it does more than backbone out of the box. You don't need to write jquery stuff. The templating is way more readable than using Backbone and underscore templating. There is less code (easier to maintain), and I like the way I can have a component approach for structuring my clientside code.

How to progress in the quest of learning Javascript [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I apologize in advance as this question isn't directly related to a coding problem or question. Many web developers start out using jQuery as an essential library due to the massive amount of plugins available. It is fairly easy and requires little knowledge to implement a plugin into your code, and use it successfully. The downside is that it can be easy for a beginning developer to ignore learning JavaScript from the ground up, and depend on jQuery plugins to get them through most situations.
After years of doing this, a "developer" learns jQuery piece by piece, but does not have the fundamental understanding of how Javascript works or the mastery required to build custom functions or plugins. This is a common turning point where developers have a yearning to learn more, and really understand how this all works. jQuery aside, developers should probably learn JavaScript first, but this is commonly disregarded amongst beginners, as jQuery is easier to understand and simpler to write.
Although this is a loaded question, I am looking for a good direction to advance my understanding of jQuery AND Javascript. Having a solid understanding of jQuery, I really want to have the knowledge and flexibility to write any code in both jQuery and traditional JavaScript. I am looking for a good direction to advance myself, and for others in similar situations to move forward on the quest of js knowledge.
What are the best books, methods, or success stories you (the community) has from your struggles with learning JavaScript? What recommendations do you have, that myself, and many others can benefit from? Keep in mind, this question is on behalf of people who write jQuery on a regular basis, but struggle to really grasp all of the necessary concepts to master the language. And also, it is for people who started learning jQuery BEFORE javascript, and wish to have a fundamental understanding of both. Thanks in advance!
This is probably the number one reason I disapprove of jQuery. That said, I suffer from a similar issue: After using Game Maker to write my games for me, I can't travel down layers of abstraction and into the realms of C++ or similar without significant effort.
Going up layers of abstraction is easy, that's why abstractions exist in the first place - if they didn't, we'd all still be writing raw machine code. Going down is significantly harder.
Ultimately, all I can really suggest is that, depending on how much "plain" JavaScript you actually know, pick up a beginner-level JS book and start from the top. Just try not to deviate into "this'd be so much easier if I just used jQuery" - if you find yourself doing this, it's bad.

Recommendations for an experienced programmer new to JavaScript? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I come from a C/Unix background, with a lot of experience in shell scripting, and some on Perl, elisp, etc. too. But now I'm getting into some work where I'll need to be developing interactive web-based interfaces, and I need to learn JavaScript. My problem is that all the resources I've found online for learning JavaScript seem to be targeted at an audience who's never programmed, and their authors don't seem much better. As soon as I see "validating user input to take the load off your server" as one of the great uses for JS, I want to scream and I feel like I can't trust anything else the author says. ;-)
Can anyone recommend good resources for an experienced programmer wanting to learn JS as a new language? Ideally I'd like to get started online, but dead tree recommendations would be welcome too, especially if I can preview them online.
A great JavaScript book for experienced programmers is Doug Crockford's JavaScript: The Good Parts. It's short, assumes you know what you're doing, is opinionated, and is not a tutorial.
My advice: Forget what you know about object oriented programming. Attempts to apply the inheritance paradigms from an OO language have repeatedly overcomplicated many, many chunks of JS code.
Prototyping is not Class construction. Object instantiation is not Class instantiation. "Classes" are not real.
There are ways to get what you want. You can even have something akin to privates - but they are not methods or members. They are merely locally scoped. Inheritance is often faked, but with mixed results, and universally at the expense of data hiding.
Javascript is prototyped. It is not object oriented. Keep that in mind every time you think something like, "Man, an interface here would be awesome..."
https://stackoverflow.com/questions/3655530/best-javascript-book-for-an-experienced-coder/3655693#3655693
https://stackoverflow.com/questions/1594159/best-book-to-learn-web-development-for-a-professional-developer
https://stackoverflow.com/questions/74884/good-javascript-books
but I will recommend these two fantastic books, which teach me a lot.
Take a look at Eloquent JavaScript. It doesn't cover everything, but it will move you towards idiomatic JavaScript programming -- things like functional programming, closures and prototypes. (The online version comes complete with a sandbox tutorial environment.) The rest, after all, is just knowing how to use references.
Javascript Guide from Mozilla Developer Network, a simple and yet informative guide, gives beginners a big picture of JS in a short time.
https://developer.mozilla.org/en/JavaScript/Guide
JavaScript: the definitive guide is one of my favorite programming books:
http://oreilly.com/catalog/9780596101992

Javascript or Python? beginner getting up to speed [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
Which language will allow a beginner to get up to speed quicker?
Basically which language of the two is easier to learn
Python is more regular, and has not needed to keep supporting every old, redundant feature forever, as Javascript has been forced to do (in order to keep supporting existing sites): these are issues that can make Python easier to learn.
However, Javascript's not too bad, especially if you can choose a reasonably rigid, modular, clean framework such as dojo (if you have to learn about every popular JS framework, or even most of them, it will, however, be a nightmare -- as it will if you have to learn the subtle bugs and incompatibilities of various browsers' implementations of JS and the DOM, rather than getting them covered up by such frameworks as dojo, jquery, or closure).
For learning Javascript, I recommend supplementing whatever tutorial you choose with Crockford's Javascript: the good parts -- it's a very thin book (which sounds like a joke, but it's true!-), fast and easy to read, and stops you from wasting your time on language features that are misconceived, too badly designed to use, or counterproductive. Crockford is a real JS guru and is well worth reading and paying attention to.
Depends what you want to do. If you're just interested in learning a programming language, I would recommend Python because:
The interactive prompt is great for learning a language
It's simple and well-designed, whereas JavaScript has a number of design flaws that can be confusing to newbies
There is a particularly high amount of introductory materials for Python.
It allows you to do all kinds of programming (server, client, games, etc.), whereas JS will limit you a bit more.
They're both pretty straightforward to learn. They more differ in terms of their typical project space - Javascript is usually utilized more for the client-side portion of web applications, while Python is often utilized for the server side of web applications and also standalone non-web apps.
What do you want to make?
The two languages are used for two completely different purposes. JavaScript does work in the browser,1 Python does work everywhere else. Pick the language based on which you want; it's useless to learn a language if you can't even use it for your project. If you want to make a website, for example, you'll have to learn both--JavaScript for the client and Python for the server.
Regardless, to answer your question, both languages are great but I'd say Python is easier to start with. JavaScript's basics are fine, but it features a lot of advanced concepts that you shouldn't have to deal with when learning your first language, IMO.
1. Yes, I'm aware that you can use JavaScript on the server-side, but those implementations are not mature and certainly not for a beginner. Python is much more suited for that kind of thing.
PHP is my thing, but I've played with Python and worked with JS. Being only somewhat skilled in both languages, Python feels nice and clean (although a little wierd) with the forced tabbing conventions and lack of semicolons. JS, on the other hand makes me feel like I need a shower. Especially after debugging in IE.
But the only real answer is the question - What do you want to do with it? Want to make websites do cool things in the browser? Go with JS. Something else? Maybe Python is better suited, as #Amber said.
Edit: As for getting up to speed, here's how it works. Your first language takes you a longer time to learn. Your second takes much less time, and after that it's not long at all since you're mostly just learning new syntax for similar things. So the solution for getting up to speed faster is to jump in right now.
I would say JavaScript is easy to learn. I had to learn it to program the Karotz. It only took about 2 months of Youtube tutorials to learn most of it.

Categories