What will be the output of the following JavaScript function? [code] <script type="text/javascript"> var name1 = "123hoidap"; function

Man Ly

New member
What will be the output of the following JavaScript function?
Code:
<script type="text/javascript">
var name1 = "123hoidap";
function DisplayName () {
var name2 = " The Best"; 
document.write(name1+name2); 
}
</script>
A. 123hoidapThe Best
B. 123hoidap The Best
C. Object required error
D. Javascript Error
 
Answer: b
Explanation: The write() method writes HTML expressions or JavaScript code to a document.The write() method is mostly used for testing: If it is used after an HTML document is fully loaded, it will delete all existing HTML. The output for the above code is 123hoidap The Best.
 

Tìm kiếm

Back
Top