Thursday, July 10, 2014

Learning JavaScript Questions


1. What are the three layers of progressive enhancement?
    Structure, presentation, and behavior

2. What part of any website is flagged as the “most important” when we think about
progressive enhancement?
    Content

3. How does using progressive enhancement benefit performance?
    Progressive enhancement ensures that you are using the proper amount of code in the correct places, which promotes strong caching of the technologies in the browser

4. In which layer of progressive enhancement does JavaScript belong?
    The behavior layer

5. Why do you generally place JavaScript at the bottom of an HTML document?
    JavaScript at the bottom allows the entire document to load before JavaScript blocks the download of subsequent objects on the page.

6. What is the most widely supported method of persistent data storage in JavaScript?
    Cookies

7. What is an anonymous function?
    A function that is declared as it runs and has no assigned name

8. When is a function considered to be a callback function?
    When it is called by another function

9. How do you elicit feedback from a user?
    Through events

10. What are the four types of DOM nodes?
    Document, Element, Text, Attribute

11. Explain what the DOM is and how it relates to HTML and JavaScript.
    The DOM is a standardized outline of an HTML document that creates access points or “hooks” in the form of nodes by which JavaScript can enter.

12. What happens if you try to set a node attribute for an attribute that does not exist on the
node already?
    The attribute node will be created automatically and then set as normal.

13. What are the three data types you can use with a variable?
    Number, String, Boolean

14. What is an associative array?
    An associative array is a normal array that uses strings as index values instead of
numbers.

15. What is a multidimensional array?
    An array that contains other arrays

16. Why is it best to position all variables at the top of your JavaScript file?
    Variables cache in JavaScript, so it’s best to cache them all at once for better referencing.

17. Why are some words reserved in JavaScript?
    Reserved words are references to terms that already exist in the JavaScript language. Therefore, using them in your code would create unwanted collisions and errors.

18. How are anonymous functions different from basic functions?
    Anonymous functions execute immediately and have no label or name assigned to them

19. What is the difference between an event handler and an event listener?
    With event handlers, you can attach only a single function to a specific event of a DOM node. This limitation does not exist with event listeners.

20. What method is used for fallback support of event listeners in IE8 and earlier?
    attachEvent()

21. What is the purpose of the preventDefault() method?
    The preventDefault() method is used to stop the default browser behavior of a given event, such as stopping the browser from executing an href or a form submit.

22. What are the five possible arguments in the XMLHttpRequest open() method, and
which are optional?
    method , file/url , asynchronous username , password. username and password are optional.

23. What does Ajax stand for?
Ajax doesn’t stand for anything; it is simply a combination of technologies meant for server communication from the client.

24. What JavaScript method is typically used to make repeat Ajax calls?
    setInterval()

25. What are the four things you want to accomplish when building your JavaScript?
    The four things are
Get the code to work.
Get the code to work well.
Make the code easy to follow.
Make the code as reusable as possible.

26. Why shouldn’t you start a function or variable name with an underscore?
    In other languages an underscore signifies privacy, which doesn’t exist in JavaScript.

27. When is it best to use an anonymous function?
    When you want to use a block of code only once

28. What is a JavaScript library?
    A JavaScript library is a collection of functions and methods presented in a reusable format.

29. What is a plug-in?
    A plug-in is a built-in way to extend the functionality of a library.

30. What is a content delivery network?
    A content delivery network is a large distributed collection of servers that deliver content based on a user’s geographical location.

31. What are the four types of ARIA roles?
    Landmark, document structure, abstract, and widget

32. What information can be returned from the Battery Status API?
    Information from the battery API includes Level, Charging (true or false), chargingTime, and dischargingTime.

33. What connection types are returned from the Network Information API?
    The network information API returns the following connection types: 2G , 3G , WIFI , ETHERNET , and UNKNOWN .

34. What are the mouse-event counterparts of touchstart , touchmove , and touchend ?
    mousedown , mousemove , and mouseup/click

35. What are the four types of events that can be created by the createEvent() method?
    UIEvents , MouseEvents , MutationEvents , and HTMLEvents

36. What are JavaScript templates used for?
    JavaScript templates are used to process and structure data inside an HTML document.




   
   

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.