JS interview Question/ Answers Set – 4
JavaScript can be used to easily modify classes and styles in an element by making use of the following syntax:
- Modify styles: document.getElementById(“input”).style.fontSize = “10”;
- Modify class: document.getElementById(“button”).className = “classname”;
. There are three types of dialog boxes, which are used in JavaScript:
- Alert: Presents users with a message and an ‘Ok’ button
- Confirm: Gives the users a window with ‘Ok’ and ‘Cancel’ buttons
- Prompt: Shows the user input, alongside ‘Ok’ and ‘Cancel’ buttons
The scope defines the accessibility of the functions and variables in an application. There are two types of scopes:
- Local – variables defined inside a function are in the local scope.
- Global – variables defined outside of a function are in the global scope.
The operating system on a client system can be known by using the JavaScript property navigator.appVersion.
The event is not called until a page is completely loaded with the entire styling from CSS and images. With the event, it will wait only till the DOM is initialized and will begin the event action. This ensures to reduce any delays in actions.
![](https://ershairykalra.com/wp-content/uploads/2022/02/W-300x153.png)