| JavaScript question answers 101-120 :👈 | 👉:JavaScript question answers 141-160 |
JavaScript Question Answers - 121-140 |
121. Why it is not advised to use innerHTML in JavaScript?
- It replaces all content instead of appending.
- It re-parses and rebuilds the DOM, which is slower.
- It can insert invalid or unsafe HTML.
- It removes existing event handlers.
122. Which method returns the inner width of a window's content area
window.innerWidth
123. What does this statement declare: var myArray = [ ];
It declares a three-dimensional array with one element, which itself contains an empty array inside another array.
124. What is this keyword?
this refers to the current execution context (the object that owns the function being executed).
125. What is negative infinity?
Number.NEGATIVE_INFINITY is a special numeric value returned when a negative number is divided by zero.
126. In JavaScript how to display a string in italic
document.write("Hello".italics());
127. What is JavaScript
JavaScript is a lightweight, interpreted, object-based scripting language used to make web pages interactive and dynamic.
128. Which method joins all elements of an array into a string
Array.join(separator)
129. Which method searches the array for an element, starting at the end, and returns its position
Array.lastIndexOf(element)
130. Which method returns the position of the last found occurrence of a specified value in a string
String.lastIndexOf(value)
131. Which method returns the number of <iframe> elements in the current window
document.getElementsByTagName("iframe").length
132. In JavaScript how to display a string as a hyperlink
document.write("Click".link("https://example.com"));
133. Which property returns the natural logarithm of 10 (approx. 2.302)
Math.LN10
134. Which property returns the natural logarithm of 2 (approx. 0.693)
Math.LN2
135. Which method Compares two strings in the current locale
str1.localeCompare(str2)
136. Which method returns the Location object for the window
window.location
137. Which method returns the natural logarithm (base E) of x
Math.log(x)
138. Which property returns the base-10 logarithm of E (approx. 0.434)
Math.LOG10E
139. Which property returns the base-2 logarithm of E (approx. 1.442)
Math.LOG2E
140. Which method searches a string for a match against a regular expression, and returns the matches
str.match(regex)
| JavaScript question answers 101-120 :👈 | 👉:JavaScript question answers 141-160 |