javascript where to declare variables

javascript where to declare variables

javascript where to declare variables

View Answers

April 4, 2012 at 4:36 PM

Javascript variable always be declared inside script tag.

var x=15;
var y=16;
var sum=x+y;
document.writeln("Sum ="+sum);

For more information, visit the following link:

Declare variables in Javascript

April 4, 2012 at 4:38 PM

JavaScript where to declare variables

To declare a variable in JavaScript me must follow the syntax. As given below


<script language="javascript">

//  declare variable or do your calculation


See an example given below that show how to declare a variable in JavaScript.

<Script Language="JavaScript">

var name, age;

name = Java;
age = 7;

In the above example name and age are two variable and further we have assigned some value to it. Always remember that the variable name must be written in small letters. document.write (); is used to print the value of variable.


Related Tutorials/Questions & Answers:
javascript where to declare variables
variables in Javascript   JavaScript where to declare variables To declare...javascript where to declare variables  javascript where to declare variables   Javascript variable always be declared inside script tag
What is JavaScript Variables ?
What is JavaScript Variables ?  Hi, My question is that What is Variable in JavaScript Programming Language. How to declare variables in JavaScript Program. Thanks
JavaScript where to place in HTML
JavaScript where to place in HTML   Where to place JavaScript code into HTML Code?   Placing JavaScript code into HTML Code In HTML, JavaScript can be declared anywhere either in <Head>? or <Body>? Tag
Where can I learn JavaScript
Where can I learn JavaScript  Hi, I have HTML knowledge and now want to learn JavaScript. Which is the best tutorials to learn JavaScript? Where can I learn JavaScript? Thanks   Hi, JavaScript is programming
Variables  What are the difference between Static variables, instance variables and local variables
How to Print Array in JavaScript
How to Print Array in JavaScript In this section you will learn about Array in JavaScript. Array are important part of all programming languages. Array in JavaScript is a variable that can hold more than one value. Array is a collection
how do i update my database with the help of update syntax in html <text/javascript>? How to write 'where' statement in this?
how do i update my database with the help of update syntax in html ? How to write 'where' statement in this?  var sqlmek="update into Student_info set(ID,s_name,l_name,address,pincode,mobile_no,mail_id)values ("; sqlmek
Variables in Java
Variable in Java In this section you will learn about variables in java. First we should know, what is variable? variable is a location in the memory where... can also declare more than one variable at at time and you can also initialize
Variables in Java
Before using variables you must declare the variables  name and type. See... Variables       Data... declare a variable we need to specify the  type of value it will hold along
JavaScript  clone JavaScript
javascript  javascript code to dynamically add table on button click.../javascript/javascriptexamples/javascript-add-row-dynamically.shtml
Declare the Navigation Rules
Declare the Navigation Rules  How to declare the Navigation Rules for JSF
Javascript  How validations are done using javascript ,with example? and interview questions on javASCRIPT
should use JavaScript? Thanks   Hi, JavaScript is scripting language that runs on browser. You have to embed JavaScript in HTML page. Please see JavaScript tutorial. Thanks
JavaScript  how to get full path of a file type in javascript
javascript  Hi deepak, how to write form validation on javascript
javascript  write a program to display implement about browsers using javascript
javaScript  How to open a browser window that cannot be resized? (HTML + Javascript
Environment variables
Environment variables  How to set Environment Variables in JAVA 6 n Tomcat 6 CLASSPATH, JAVA_HOME, PATH, & CATALINA variables plzzz plzz help me
javascript  i have just learned javascript... can you tell me what kind of applications can be made by javascript?? thank you
How to Declare Abstract Class in PHP ?
How to Declare Abstract Class in PHP ?  hi, I am a PHP Beginners. As i am trying to make an application where i trying to declare the abstract class of PHP. Please any one explain me how to declare abstract class in PHP program
Declare Cursors in SQL
Declare Cursors in SQL       Declare Cursors in SQL is used to define cursor and its... 'Declare Cursors in SQL'. To grasp the example, we create a table 'Stu_Table
How to declare NSMatrix
How to declare NSMatrix  How to declare NSMatrix in XCode can anyone explain it with example
javascript  how to set the request or session attribute in javascript head part of jsp page
javascript  Hi sir, This is sinduri, i want to learn javascript, so plz can u help to learn
javascript  hi sir, if i want to learn javascript. what concepts i want to know
ModuleNotFoundError: No module named 'declare'
ModuleNotFoundError: No module named 'declare'  Hi, My Python... 'declare' How to remove the ModuleNotFoundError: No module named 'declare... to install padas library. You can install declare python with following command
JAVASCRIPT  I have one textbox and I want to validate that it must start with number(1-0). can anyone tell me a javascript for that ? thanks in advance
JavaScript clearTimeOut method
JavaScript clearTimeOut method       JavaScript's HTML DOM window object method clearTimeOut() method is used to stop or clear the time out variables value
Javascript   Javascript to check Numeric entry in checkbox.....   Hi Please find the following code for numeric entry validation in javascript function validateBox(){ var data=document.myForm.someText.value
javascript  hi, I was actually working on to calculate the number of days between two dates of yyyy-mm-dd format using javascript, and when i click on button then number of days should be display in textbox