• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 10 pages
Exam (elaborations)

Javascript W3Schools Questions And Answers

Document preview thumbnail
Preview 2 out of 10 pages

JAVASCRIPT W3SCHOOLS QUESTIONS AND ANSWERS

Content preview

JAVASCRIPT W3SCHOOLS
QUESTIONS AND ANSWERS

document.getElementById("demo").innerHTML = "Hello JavaScript"; - ANSWER-Get
element by ID demo and replace the text in it with 'Hello JavaSript'
onclick="document.getElementById('myImage').src='pic_bulboff.gif'" - ANSWER-
Change the src on click
document.getElementById("demo").style.display = "none"; - ANSWER-Hide the demo
element
document.getElementById("demo").style.display = "block"; - ANSWER-Display the
'demo' element.
<script>
document.getElementById("demo").innerHTML = "My First JavaScript";
</script> - ANSWER-In HTML, JavaScript code must be inserted between <script> and
</script> tags.
JavaScript in <head> or <body>? - ANSWER-Scripts can be placed in the <body>, or in
the <head> section of an HTML page, or in both.
<script src="myScript.js"></script> - ANSWER-Scripts can also be placed in external
files:
<script src="https://www.w3schools.com/js/myScript1.js"></script> - ANSWER-External
scripts can be referenced with a full URL or with a path relative to the current web page.
<script src="/js/myScript1.js"></script> - ANSWER-This example uses a script located in
a specified folder on the current web site:
<script src="myScript1.js"></script> - ANSWER-This example links to a script located in
the same folder as the current page
document.write(5 + 6); - ANSWER-Using document.write() after an HTML document is
fully loaded, will delete all existing HTML:
window.alert(5 + 6); - ANSWER-You can use an alert box to display data:

, console.log(5 + 6); - ANSWER-For debugging purposes, you can use the console.log()
method to display data.
var person = "John Doe", carName = "Volvo", price = 200; - ANSWER-You can declare
many variables in one statement.


Start the statement with var and separate the variables by comma:
var person = "John Doe",
carName = "Volvo",
price = 200; - ANSWER-A declaration can span multiple lines:
z = "Hello" + 5; - ANSWER-Adding a number and a string will return a string.
&& - ANSWER-logical and
|| - ANSWER-logical or
! - ANSWER-logical not
typeof - ANSWER-Returns the type of a variable
instanceof - ANSWER-Returns true if an object is an instance of an object type
person.name = person["name"] - ANSWER-Member
++ -- - ANSWER-Prefix Increment, Prefix Decrement
var person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"}; - ANSWER-
JavaScript objects are written with curly braces.


Object properties are written as name:value pairs, separated by commas.
var cars = ["Saab", "Volvo", "BMW"]; - ANSWER-JavaScript arrays are written with
square brackets.


Array items are separated by commas.


Array indexes are zero-based, which means the first item is [0], second is [1], and so
on.
typeof "John"

Document information

Uploaded on
November 1, 2025
Number of pages
10
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$13.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
EduSprint
3.9
(8)
Sold
70
Followers
5
Items
7078
Last sold
1 day ago




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions