Answer & Solution
<script>
element and is accessible within the script, printing 'Hello' when using console.log.
element and is accessible within the script, printing 'Hello' when using console.log.",
"answerCount": 4,
"dateCreated": "2024-05-24",
"author": {
"@type": "Organization",
"name": "MYTAT"
},
"suggestedAnswer": [
{
"@type": "Answer",
"text": "Hello"
},
{
"@type": "Answer",
"text": "Undefined"
},
{
"@type": "Answer",
"text": "Error"
},
{
"@type": "Answer",
"text": "'Hello'"
}
],
"acceptedAnswer": {
"@type": "Answer",
"text": "Hello",
"dateCreated": "2024-05-24",
"author": {
"@type": "Organization",
"name": "MYTAT"
}
}
}
}
<br>
<br>
<script>
<br>
var globalVar = 'Hello'; <br>
console.log(globalVar); <br>
</script>
<script>
element and is accessible within the script, printing 'Hello' when using console.log.
What is the purpose of using global variables in CSS?
A). To store values that can be reused throughout a CSS stylesheet
B). To restrict the scope of variables within specific CSS rules
C). To override default browser styles
D). To prevent conflicts between CSS selectors
Which statement accurately describes the scope of global variables declared in HTML?
A). Global variables are accessible only within the <script>
element where they are declared
B). Global variables are accessible only within the <body>
element where they are declared
C). Global variables are accessible throughout the entire HTML document
D). Global variables are accessible only within the <head>
element where they are declared
What is the purpose of using global variables within HTML elements using custom data attributes?
A). To store and retrieve data specific to each HTML element
B). To restrict access to data within specific HTML elements
C). To create variables with limited scope within HTML elements
D). To avoid using JavaScript for data manipulation
How can you declare a global variable in HTML using the data-* attribute within an HTML element?
A). <div data-global-var='value'>
</div>
B). <div global-var='value'>
</div>
C). <div data='global-var: value'>
</div>
D). <div global data-var='value'>
</div>
How can you access a global variable defined in one <script>
element from another <script>
element in HTML?
A). By using the global attribute on both elements
B). By using the var keyword to declare the variable as global
C). By using the window object to access the global variable declared in the first script element
D). By using the <global>
element to link the variables
Which of the following is a potential disadvantage of using global variables extensively within HTML documents?
A). Increased risk of naming conflicts and data pollution
B). Improved data organization and accessibility
C). Reduced dependency on JavaScript
D). Improved performance and efficiency
What is the correct syntax for defining a global variable in HTML using the <script>
element?
A). <script globalVar='value'>
B). <script var='globalVar' value='value'>
C). <script global var='globalVar' value='value'>
</script>
D). <script global='globalVar' value='value'>
</script>
What is the purpose of using the defer attribute in a <script>
element in HTML?
A). To delay the loading of the script until after the HTML content is parsed
B). To prevent the script from executing unless triggered manually
C). To execute the script asynchronously
D). To specify the script's global variables
Which CSS function is used to access the value of a global variable defined in HTML?
A). var()
B). global()
C). getGlobalVar()
D). accessGlobal()
What is a global variable in HTML?
A). A variable declared inside a function
B). A variable declared outside of any function or block
C). A variable declared within an HTML element
D). A variable declared with the global attribute