JavaScript variables

 Variables

In this article we are goanna to see about Variable in JavaScript which is most important when you are going to start your career in JavaScript. Please read and enjoy this article if you want to give any feedback about your experience, we welcome.



variables are used to hold a value. It can hold any value, from primitives to objects.



A variable is written with a combination of letters, numbers and special characters _(underscore) and $(dollar) with the first letter being an alphabet.

Ex – a, a5, tmp, total_cash etc.

Need to keep in mind while using variables in JavaScript:

  • Variable can contain combination of letters, digits, underscores(_), and dollar signs($)
  • Must begin with a letter A-Z or a-z or underscore or dollar sign.
  • A variable name can’t start with a number.
  • Must not contain any space characters.
  • JavaScript is case-sensitive.
  • Can’t use reserved keywords


Example:

<html>

<head>

<title>JavaScript Tutorial</title>

</head>

<body>

<h1>Inline JavaScript</h1>

<script type=“text/javascript”>

var a = 10;

document.write(a);

</script>

</body>

</html>


Share:

0 comments

Please leave your comments...... Thanks