Typical answers include form validations, user action confirmations, updating an Internet page dynamically and other such answers. I usually ask this question first just to get the candidate talking about JavaScript and see if they have in fact used JavaScript for something.
How do you access an element in an HTML document with JavaScript?
Give the element an ID attribute and then use JavaScript’s getElementById() function to access that element.
How do you determine how many characters are in a JavaScript string?
With the length property of the JavaScript string object.
What datatypes are supported by JavaScript?
Number, String, Undefined, null, Boolean. At a minimum, the candidate should identify Number and String.
How do you create a date in JavaScript?
With the Date object: new Date()
Where does JavaScript date object pull it’s date from?
From the client machine.
What does the isNaN function do?
Returns true is the value provided is not a numeric value and false if the number provided is a numeric value.
What is the difference between JavaScript and Java?
They are completely different languages.
How do you comment JavaScript code?
For single-line comments, begin the line with consecutive forward slashes (//). To comment a block of code, wrap it with /* code */.