| JavaScript question answers 161-180 :👈 | 👉:JavaScript question answers 201-220 |
JavaScript Question Answers - 181-200 |
181. Define unescape() and escape() functions
escape() encodes a string so it can be transmitted safely (deprecated).
unescape() decodes an encoded string (deprecated).
182. What is the difference between .call() and .apply()
- call(): Invokes a function with a given this value and arguments provided individually.
- apply(): Invokes a function with a given this value and arguments provided as an array.
183. How can you convert the string of any base to integer in JavaScript
Use parseInt(string, base). Example: parseInt("1010", 2) → 10.
184. What are the different types of errors in JavaScript
- Load-time errors
- Run-time errors
- Logical errors
185. Explain how to read and write a file using JavaScript
- In browsers: Use File API for reading, and downloads or server APIs for writing.
- In Node.js: Use fs.readFile() and fs.writeFile().
186. What are the two basic groups of datatypes in JavaScript
- Primitive types (Number, String, Boolean, Null, Undefined, Symbol, BigInt)
- Reference types (Objects, Arrays, Functions)
187. Explain the unshift() method
arr.unshift(element1, ...) adds elements to the beginning of an array and returns the new length.
188. Which statement throws (generates) an error
throw new Error("message");
189. Which method converts the date portion of a Date object into a readable string
date.toDateString()
190. Which method converts a number into an exponential notation
num.toExponential(fractionDigits)
191. Which method formats a number with x numbers of digits after the decimal point
num.toFixed(x)
192. Which method returns the date as a string, using the ISO standard
date.toISOString()
193. Which method returns the date as a string, formatted as a JSON date
date.toJSON()
194. Which method returns the date portion of a Date object as a string, using locale conventions
date.toLocaleDateString()
195. Which method converts a string to lowercase letters, according to the host's locale
str.toLocaleLowerCase()
196. Which method converts a Date object to a string, using locale conventions
date.toLocaleString()
197. Which method returns the time portion of a Date object as a string, using locale conventions
date.toLocaleTimeString()
198. Which method converts a string to uppercase letters, according to the host's locale
str.toLocaleUpperCase()
199. Which method converts a string to lowercase letters
str.toLowerCase()
200. Which method returns the topmost browser window
window.top
| JavaScript question answers 161-180 :👈 | 👉:JavaScript question answers 201-220 |