Thursday, January 7, 2010

JavaScript Gurus Test Your Knowledge

Join GeekyClown's Fan Page on Facebook | Follow me on Twitter
I finally got around to purging my old files and found an old test I gave to my JavaScript class about five years ago and discovered, "Wow! This test SUCKED!!!"  For my JavaScript loving readers, feel free to take a crack at it for fun.  For my students taking JavaScript with me this year, have no fear, this test has been completely purged and...no questions will be repeated.

1. What methods allow you to change the case of a string?

2. What are the differences among slice, substring, and substr?

3. The String method, toUppercase(), returns a string converted to uppercase characters.
(True)              (False)
 
4. The difference between indexOf and lastIndexOf is that
a. indexOf counts index numbers from the beginning of the string (index 0 represents the first character in the string) and lastIndexOf counts index numbers from the end of the string (index 0 represents the last character in the string).
b. indexOf searches forward through a string and lastIndexOf searches backward through a string.
c. indexOf returns -1 if the search string is not found and lastIndexOf returns false if the search string is not found.
d. indexOf returns the index of the first character of the first occurrence of the search string and lastIndexOf returns the index of the last character of the first occurrence of the search string.
e. indexOf returns the index of the first character of the first occurrence of the search string and lastIndexOf returns the index of the first character of the last occurrence of the search string.
 
5. The String method, _______________, allows you to retrieve a character from a string using its index number.

6. How does JavaScript measure dates?

7-8. Describe the four ways of creating a Date object and give an example of each.

9. What range of values does the getDay method return?

10. What range of values does the getDate method return?

11. Why is it essential to name each frame in a frameset?

12-13. List and describe five window synonyms supported in JavaScript.

14. List three window methods that emulate the action of a visitor clicking a button on the browser toolbar.
 
15. If you create a pop-up window using the following code
var play = window.open("myDoc.html", "PlayWin")
the code:
PlayWin.close() will close the window.
(True)              (False)
 
16. When you list the features you want on a window in the features argument of the window.open method, you should separate them with a _____________.

17. What advantage does a server-side script such as FormMail have over a simple mailto URL when it comes to processing form data?

18. Describe the differences between the get and post methods.  Which is preferred?  Why?

19. Explain how the special keyword, this, works.

20. Explain how the special keyword, return, works.

21. What is a hidden form element?  What good is it if visitors can't see it?
 
22. Which of the following is not part of the URL-encoding process?
a. Each element name and value is separated by an equals sign (=).
b. An ampersand (&) is placed between name/value pairs.
c. Spaces in the input are indicated with a plus sign (+).
d. Ampersands (&), quotes ("), and percent signs (%) are preceded by a backslash (\).
e. None of the above.  All are part of the URL-encoding process.
 
23-25. Match the following form terms with the appropriate description.
a. hidden
d. selected
b. checkbox
e. checked
c. radio
 
1. Only one elements of this type can be chosen at any one time.
2. One or more elements of this type can be chosen at one time.
3. Makes a radio button or checkbox selected by default.
4. Can be used to store information, but the element is not visible to the visitor.
5. Makes a drop-down menu item selected by default.
 
26-30. Match the following benefits and disadvantages with the type of form validation it best fits.
a. batch form validation
c. real-time validation
b. client-side form validation
d. server-side form validation

1. Easy to bypass correcting a problem.
2. The browser does not need to support client-side scripting or have JavaScript turned on in order for it to run.
3. Performed immediately upon completion of a field entry.
4. Not performed until the form is submitted.
5. Fast and responsive.
6. Increases the load on the server leaving it less free to handle other requests quickly.
7. The entire form is checked once, in one fell swoop.
8. Visitor is alerted as soon as an error is made.
9. Will not be run if the browser does not support JavaScript or JavaScript is not turned on.
10. Slow and unresponsive.
 
31. What is a cookie?

32. List and describe three well-meaning uses for cookies.

33. Chips Ahoy! make the best cookies.
(True)              (False)

34. List and describe two not-so-well-meaning uses for cookies.

35-37. List and describe the six cookie ingredients.

38. What is DHTML?

39. To access the width of the current window in most DOM2 compliant browsers, the proper dot notation is: ______________________________.

40. What is a constructor function?

41. The ________________ function is a built-in general constructor function that allows you to create a custom object.
 
42-44. Match each of the following cookie ingredients with its appropriate description.
a. domain
d. path
b. expires
e. secure
c. name
f. value

1. This ingredient defines the lifespan of a cookie.
2. This ingredient labels the information you want to store.
3. This ingredient specifies the Web site that is allowed to access the cookie.
4. This ingredient indicates whether a secure HTTP connection is required to access the cookie.
5. This ingredient specifies the URL directories allowed to access the cookie.
6. This ingredient is the information you want to save during or between sessions.
 

-----------------------------------------------------------------------------------------------------------------------------------------------

Get the answers here:Answer Key

No comments:

Post a Comment