*
JavaScript Question Answers - 281-300
|
|
281. What is variable typing in JavaScript?
It is the dynamic assignment of types to variables depending on the value assigned at runtime.
282. What is the use of Void(0)?
void(0) is used to prevent the browser from refreshing or navigating when a link is clicked. Example:
<a href="javascript:void(0);">Click</a>
283. Which statement marks a block of statements to be executed while a condition is true
while (condition) { ... }
284. Is JavaScript case sensitive? Give an example
Yes, JavaScript is case sensitive. Example:
var name = "John"; and var Name = "Doe"; are two different variables.
285. Which method returns the value of a String object
str.valueOf()
286. Which method converts an array to a string, and returns the result
arr.toString()
287. Which method converts a number to a string
num.toString()
288. Which method converts a Date object to a string
date.toString()
289. Which method converts the time portion of a Date object to a string
date.toTimeString()
290. Which method converts a string to uppercase letters
str.toUpperCase()
291. Which method converts a Date object to a string, according to universal time
date.toUTCString()
292. Which method removes whitespace from both ends of a string
str.trim()
293. Which statement marks the block of statements to be executed when an error occurs in a try block, and implements error handling
catch (error) { ... }
294. Which keywords are used to handle exceptions
try, catch, finally, throw
295. Which method adds new elements to the beginning of an array, and returns the new length
arr.unshift(element1, element2, ...)
296. How do you submit a form using JavaScript?
document.forms["formName"].submit(); or document.getElementById("formId").submit();
297. Which method returns the number of milliseconds in a date since midnight of January 1, 1970, according to UTC time
date.getTime()
298. Which method returns the primitive value of an array
arr.valueOf()
299. Which method returns the primitive value of a String object
str.valueOf()
300. Which method returns the primitive value of a number
num.valueOf()
*