article

javascript interview questions

by techrepublic

[WHAT]

  1. ] here is a list of some javascript interview questions by techrepublic, along with my answer and their(the original sites) answer

[WHY]

  1. ] test your javascript knowledge
  2. ] prepare for your javascript interview
  3. ] learn more about javascript

[WHERE]

  1. ] REVIEW OUR FULL LIST OF JAVASCRIPT INTERVIEW QUESTIONS
    1. ] javascript interview - questions and answers? - 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.
  2. ] READ THE FULL ARTICLE
    1. ] http://www.techrepublic.com/blog/software-engineer/javascript-interview-questions-and-answers/ by techrepublic

[WHEN]

  1. ] 2015-05-30

[EXAMPLE]

  1. ]

[REFERENCE]

  1. ]
    1. ] g qry js interview questions

 

  1. ]  what is a global variable?
    1. ] a variable that is available/accessible across your entire js application
    2. ] 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).
  2. ] how are they declared?
    1. ] var global; declare it inside any script tag outside of any enclosing function
    2. ] The var keyword is used to declare a local variable or object, while omitting the var keyword creates a global variable.
  3. ] what are the problems with using globals?
    1. ] any code from anywhere in your app/site can access it, change it, NAMING conflicts between local/global
    2. ] 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.
  4. ] how do you organize your code?
    1. ] folder{/js} / app{sospep} / page OR component {view/libraries, add/library, dlgSelect3, dlgSelect4, dlgSendMail} / subcomponents {navHeader, detailPanel, ....}
    2. ] 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).
  5. ] what are the javascript types?
    1. ] by types i am assuming the native javascript objects like ] string, ] number ] etc 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 ] Array, ] regexp ] Math ] function ] Date ** ]  boolean, ?] global?, ] Null ] Undefined
    2. 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.
  6. ] what is the difference between null and undefined?
    1. ] 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
    2. 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 odd results -- it returns true for a null or undefined comparison if they are either.
  7. ] what is javascripts 'this' keyword?
    1. ] self referencing object, refer to the current instance of an object,
    2. ] JavaScript's this 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 this keyword will point to the object that generated the event
  8. ] what is event bubbling
    1. ] 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
    2. ] 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
  9. ] do you have a framework preference?
    1. ] i love jquery, i try to think about when and where i am using it, * framework VS libraries () 
    2. ] This open-ended question has the potential to spawn a good conversation. There are the vastly popular frameworks like jQuery, although you might be surprised when the person tells you about the framework they developed or even played the contributor role.
  10. ] what are your thoughts on using frameworks?
    1. ] 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
    2. ] 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 (Knockout, postal.js, jQuery, 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.
  11. ] how are errors gracefully handled in js
    1. ] try , catch , finally code blocks, wrap your code in these to detect and trap runtime errors
    2. ]  
  12. ] explain how inheiritance works in js
    1. ]
  13. ] how do javascript timers work?
    1. ] setTimeout(), setInterval()
  14. ] what is the drawback of js timers?
    1. ]
Details Photos Edit more

Details

ID: 2616

NAME: javascript-interview-questions

DESCRIPTION: javascript-interview-questions ] by ... @techrepublic - A collection of interview questions, includes my answers, their answers

AUTHOR: article.author/s

EDITOR: article.editor/s

PUBLISHER: article.publisher/s

STATUS: Write

PRIORITY: 0

OWNER ID: 75

Content Photos Edit more

photos

page_photo

actions

Email Email-Owner SMS and