*
Previous JavaScript question answers 241-260 JavaScript question answers 281-300 Next

JavaScript Question Answers - 261-280

261. Which method returns the value of a String object

str.valueOf()

262. Which method converts an array to a string, and returns the result

arr.toString()

263. Which method converts a number to a string

num.toString()

264. Which method converts a Date object to a string

date.toString()

265. Which method converts the time portion of a Date object to a string

date.toTimeString()

266. Which method converts a string to uppercase letters

str.toUpperCase()

267. Which method converts a Date object to a string, according to universal time

date.toUTCString()

268. Which method removes whitespace from both ends of a string

str.trim()

269. Which statement marks the block of statements to be executed when an error occurs in a try block, and implements error handling

catch (error) { ... }

270. Which keywords are used to handle exceptions

try, catch, finally, throw

271. Which method adds new elements to the beginning of an array, and returns the new length

arr.unshift(element1, element2, ...)

272. How do you submit a form using JavaScript?

document.forms["formName"].submit(); or document.getElementById("formId").submit();

273. Which method returns the number of milliseconds in a date since midnight of January 1, 1970, according to UTC time

date.getTime()

274. Which method returns the primitive value of an array

arr.valueOf()

275. Which method returns the primitive value of a String object

str.valueOf()

276. Which method returns the primitive value of a number

num.valueOf()

277. Which method returns the primitive value of a Date object

date.valueOf()

278. Which statement declares a variable

var, let, or const

279. How do you create a new object in JavaScript?

- Using object literal: var obj = {};
- Using constructor: var obj = new Object();
- Using class: class MyClass {} let obj = new MyClass();

280. What is called Variable typing in JavaScript

Variable typing means a variable can hold values of different types at different times. Example:
var x = 10; x = "hello";

Back to Index
Previous JavaScript question answers 241-260 JavaScript question answers 281-300 Next
*
*