edit-article
Home
Up
Delete
Article Name:
Article Description:
javascript-interview-questions ] by ... @techrepublic - A collection of interview questions, includes my answers, their answers
Chapter ID/Name:
Status:
Write
Writing
Written
Add Photo:
Owner ID:
Content:
use HTML
Edit Content
<h1 style="text-align: center;">javascript interview questions</h1> <h2 style="text-align: center;">by techrepublic</h2> <h2>[WHAT]</h2> <ol> <li>] here is a list of some javascript interview questions by techrepublic, along with my answer and their(the original sites) answer</li> </ol> <h2>[WHY]</h2> <ol> <li>] test your javascript knowledge</li> <li>] prepare for your javascript interview</li> <li>] learn more about javascript</li> </ol> <h2>[WHERE]</h2> <ol> <li><strong>] REVIEW OUR FULL LIST OF JAVASCRIPT INTERVIEW QUESTIONS</strong></li> <ol> <li>] <a href="/view/steps?id=136" target="_blank">javascript interview - questions and answers?</a> - 101+ javascript interview questions, compiled from several different sources, organized into categories, ranked by difficulty(beginner, intermediate, advanced) . User our javascript interview questions app to practice your answers or review the answers.</li> </ol> <li><strong>] READ THE FULL ARTICLE</strong></li> <ol> <li>] <a href="http://www.techrepublic.com/blog/software-engineer/javascript-interview-questions-and-answers/" target="_blank">http://www.techrepublic.com/blog/software-engineer/javascript-interview-questions-and-answers/</a> by techrepublic</li> </ol></ol> <h2>[WHEN]</h2> <ol> <li>] 2015-05-30</li> </ol> <h2>[EXAMPLE]</h2> <ol> <li>]</li> </ol> <h2>[REFERENCE]</h2> <ol> <li>]</li> <ol> <li>] g qry js interview questions</li> </ol></ol><hr /> <p style="text-align: left;"> </p> <ol> <li> <div style="text-align: left;"><strong>] what is a global variable?</strong></div> </li> <ol> <li> <div style="text-align: left;">] a variable that is available/accessible across your entire js application</div> </li> <li> <div style="text-align: left;">] Global variables are available throughout your code: that is, the variables have no scope. Local variables scope, on the other hand, is restricted to where it is declared (like within a function).</div> </li> </ol> <li> <div style="text-align: left;"><strong>] how are they declared?</strong></div> </li> <ol> <li> <div style="text-align: left;">] var global; declare it inside any script tag outside of any enclosing function</div> </li> <li> <div style="text-align: left;">] The var keyword is used to declare a local variable or object, while omitting the var keyword creates a global variable.</div> </li> </ol> <li> <div style="text-align: left;"><strong>] what are the problems with using globals?</strong></div> </li> <ol> <li> <div style="text-align: left;">] any code from anywhere in your app/site can access it, change it, NAMING conflicts between local/global</div> </li> <li> <div style="text-align: left;">] Most JavaScript developers avoid globals. One reason why is they're averse to naming conflicts between local and globals, Also, code that depends on globals can be difficult to maintain and test.</div> </li> </ol> <li> <div style="text-align: left;"><strong>] how do you organize your code? </strong></div> </li> <ol> <li> <div style="text-align: left;">] folder{/js} / app{sospep} / page OR component {view/libraries, add/library, dlgSelect3, dlgSelect4, dlgSendMail} / subcomponents {navHeader, detailPanel, ....}</div> </li> <li> <div style="text-align: left;">] The key concept here is to get an idea of how the candidate maintains and designs code. Do they design code that is specific to an application with no possible reuse? Do they use class inheritance or the module pattern to build reusable code? These approaches allow multiple developers to work on a project without stepping on their coworkers' toes. In addition, testing modular code or classes is easier to approach than a jumbled mess of code thrown together (look around the Web, and you'll find plenty of examples).</div> </li> </ol> <li> <div style="text-align: left;"><strong>] what are the javascript types?</strong></div> </li> <ol> <li> <div style="text-align: left;">] by types i am assuming the <a href="/view/article?id=1695" target="_blank">native javascript objects</a> like ] <strong>string, ] number ] etc </strong>that are the building blocks used to construct your js programs, js does not have typical 'type' system like (c, c#, java etc) that enforces declared types like int, double, char, ... ] the remaining native global objects are <strong>] Array, ] regexp ] Math ] function ] Date</strong> ** ] boolean, ?] global?, ] Null ] Undefined</div> </li> <li> <div style="text-align: left;">Unlike Java or C#, JavaScript is a loosely-typed language (some call this weakly typed); this means that no type declarations are required when variables are created. Strings and numbers can be intermixed with no worries. JavaScript is smart, so it easily determines what the type should be. The types supported in JavaScript are: Number, String, Boolean, Function, Object, Null, and Undefined.</div> </li> </ol> <li> <div style="text-align: left;"><strong>] what is the difference between <em>null</em> and <em>undefined</em>?</strong></div> </li> <ol> <li> <div style="text-align: left;">] undefined is the object returned when you are trying to access something that has not been declared, null is where an object exists but it has not been assigned/or does not have any value</div> </li> <li> <div style="text-align: left;">The value of a variable with no value is undefined (i.e., it has not been initialized). Variables can be emptied by setting their value to null. You can test for each using the === (three equal signs) or == (two equal signs) for comparison checking. The big difference is the latter uses coercion, which can have some <a href="http://ecma-international.org/ecma-262/5.1/#sec-11.9.3">odd results</a> -- it returns true for a null or undefined comparison if they are either.</div> </li> </ol> <li> <div style="text-align: left;"><strong>] what is javascripts <em><a href="/view/article?id=2617" target="_blank">'this'</a></em> keyword?</strong></div> </li> <ol> <li> <div style="text-align: left;">] self referencing object, refer to the current instance of an object,</div> </li> <li> <div style="text-align: left;">] JavaScript's <em>this</em> keyword normally refers to the object that owns the method, but it depends on how a function is called. Basically, it points to the currently in scope object that owns where you are in the code. When working within a Web page, this usually refers to the Window object. If you are in an object created with the new keyword, the this keyword refers to the object being created. When working with event handlers, JavaScript's <em>this</em> keyword will point to the object that generated the event</div> </li> </ol> <li> <div style="text-align: left;"><strong>] what is <em>event bubbling</em></strong></div> </li> <ol> <li> <div style="text-align: left;">] browsers mechanism for detecting user actions and reflecting them up through the DOM, ] programmer writes 'event handler's' to detect events and then code that will execute when that event ] prev - differing mechanisms in major browsers ie/mozilla</div> </li> <li> <div style="text-align: left;">] Event bubbling describes the behavior of events in child and parent nodes in the Document Object Model (DOM); that is, all child node events are automatically passed to its parent nodes. The benefit of this method is speed, because the code only needs to traverse the DOM tree once. This is useful when you want to place more than one event listener on a DOM element since you can put just one listener on all of the elements, thus code simplicity and reduction. One application of this is the creation of one event listener on a page's body element to respond to any click event that occurs within the page's body</div> </li> </ol> <li> <div style="text-align: left;"><strong>] do you have a framework preference?</strong></div> </li> <ol> <li> <div style="text-align: left;">] i love jquery, i try to think about when and where i am using it, * framework VS libraries () </div> </li> <li> <div style="text-align: left;">] This open-ended question has the potential to spawn a good conversation. There are the vastly popular frameworks like <a href="http://www.techrepublic.com/article/simplify-javascript-development-with-jquery/6187023" target="_blank">jQuery</a>, although you might be surprised when the person tells you about the framework they developed or even played the contributor role.</div> </li> </ol> <li> <div style="text-align: left;"><strong>] what are your thoughts on using frameworks?</strong></div> </li> <ol> <li> <div style="text-align: left;">] makes development easier, invaluable to developers, especially non experts, ] cross browser is less significant the previously, it does still have an impact, ] ] code dload impact on the desktop is small ? insignificant</div> </li> <li> <div style="text-align: left;">] The answer to the second question gives you an idea of the candidate's feelings about open source (well, that is the way I see it). There are so many open source options available today (<a href="http://knockoutjs.com/" target="_blank">Knockout</a>, <a href="http://www.techrepublic.com/blog/programming-and-development/utilize-javascript-messaging-with-postaljs/5321" target="_blank">postal.js</a>, <a href="http://www.techrepublic.com/blog/webmaster/how-to-get-started-with-jquery/1415" target="_blank">jQuery</a>, etc.), and a developer's time is very valuable, so why reinvent the wheel? These open source options provide robust code that has been thoroughly tested by an army of developers. From my perspective, I want developers who will use whatever is available to meet a project's demands. Plus, the interviewee might introduce you to something you've never used.</div> </li> </ol> <li> <div style="text-align: left;"><strong>] how are errors gracefully handled in js</strong></div> </li> <ol> <li> <div style="text-align: left;">] try , catch , finally code blocks, wrap your code in these to detect and trap runtime errors</div> </li> <li> <div style="text-align: left;">] </div> </li> </ol> <li> <div style="text-align: left;"><strong>] explain how inheiritance works in js</strong></div> </li> <ol> <li> <div style="text-align: left;">]</div> </li> </ol> <li> <div style="text-align: left;"><strong>] how do javascript timers work?</strong></div> </li> <ol> <li> <div style="text-align: left;">] setTimeout(), setInterval()</div> </li> </ol> <li> <div style="text-align: left;"><strong>] what is the drawback of js timers?</strong></div> </li> <ol> <li> <div style="text-align: left;">]</div> </li> </ol></ol>