To avoid cross-site scripting (XSS) attacks, instead of innerHTML, use _________.
- textContent
- appendChild
- createElement
- setAttribute
To prevent XSS attacks, it's recommended to use the textContent property. Unlike innerHTML, which can execute scripts, textContent only sets the text content of an element, making it safer for user-generated input.
Loading...
Related Quiz
- To prevent variables from being added to the global object, it is common to use a(n) _______ function expression.
- What is the output of the arithmetic expression 7 / 0 in JavaScript?
- If you are developing a real-time application where any blocking of the event loop can lead to critical issues, how might you implement a "for" loop to process an array of data without introducing any blockage?
- You are working on a form validation feature where you want to select all input elements within a form. Which method allows you to select all input elements within a specific form element?
- A callback function is passed as an ________ to other functions and is executed after its parent function has completed.