shreyaskudav Posted June 28, 2011 Report Share Posted June 28, 2011 <script type="text/javascript">var firstname;firstname="Hege";document.write(firstname);document.write("<br />");firstname="Tove";document.write(firstname);</script>What does the RED script do?And there is no " " inside the brackets..? Link to comment Share on other sites More sharing options...
brucemand Posted June 28, 2011 Report Share Posted June 28, 2011 What does the RED script do?And there is no " " inside the brackets..?it's referring to the variable of that name.it will write firstname - which contains "Hege", and hence document will write "Hege"i believe the correct jargon is, it's being referenced ? Link to comment Share on other sites More sharing options...
Ingolme Posted June 28, 2011 Report Share Posted June 28, 2011 document.write() prints to the page, that's all. If it's called after the page has finished loading then the page will be cleared so it can start writing.You only need quotation marks when you're using a literal string. If you want to print the value of a variable you use the variable's name. Link to comment Share on other sites More sharing options...
ShadowMage Posted June 28, 2011 Report Share Posted June 28, 2011 i believe the correct jargon is, it's being referenced ?It is referencing the variable, which is in turn referencing a memory location holding that specific value. Link to comment Share on other sites More sharing options...
Drycodez Posted June 28, 2011 Report Share Posted June 28, 2011 (edited) In javascript, the keyword "var," helps to store data, so dat it can be use latter in the document.Var firstname= "Hege";this variable that have a name "firstname" holds the value "Hege"document.write(firstname); this is telling the "document" to use the method "write" to write the value of the word the variable (firstname) holds in the html doc.THE REASON THERE ARE NO QUOTATION MARKS ( " ), ITS BECAUSE WE WANT THE DOCUMENT TO WRITE WHAT IS INSIDE THE VARIABLE AND NOT TO WRITE JUST PLAIN TEXT.i started reading js 3days back and GOD has been GOOD to me! Edited June 28, 2011 by O. Samuel Link to comment Share on other sites More sharing options...
thescientist Posted June 28, 2011 Report Share Posted June 28, 2011 In javascript, the keyword "var," helps to store data, so dat it can be use latter in the document.Var firstname= "name";holds the value "name"document.write(name); this is telling the document, to use the method "write" to write down the value of the word the variable holds. that's not entirely correct. aside from wether or not you have to use var or whether one should be using document.write, to print out the value of firstname i.e. "name", would actually be done like this:var firstname= "name";document.write(firstname); Link to comment Share on other sites More sharing options...
Drycodez Posted June 28, 2011 Report Share Posted June 28, 2011 (edited) Ok Edited June 28, 2011 by O. Samuel Link to comment Share on other sites More sharing options...
Drycodez Posted June 28, 2011 Report Share Posted June 28, 2011 (edited) . Edited June 28, 2011 by O. Samuel Link to comment Share on other sites More sharing options...
brucemand Posted June 29, 2011 Report Share Posted June 29, 2011 ......i started reading js 3days back and GOD has been GOOD to me!Amen to that !! And the admins here are Angels !! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now