The HTML <script> Tag
- Inside the <head> tag
- Inside the <body> tag
- In an external file
The most common attributes of <script> tag are src and type.
The src attribute specifies the URI of an external script. A URI or Uniform Resource Identifier is a sequence of characters that identifies a logical or physical resource.
The type attribute defines the type of file represented.
If not, the output in your browser will be:
The output of this code in the browser would be:
- Fixed values
- Variable values
The fixed values are Literals while the variable values are Variables.
A variable is simply the name of the storage location where we store the data and we can easily alter it. In the above code, operand1, operand2 and sum are the variables that we operated on.
In the above code, we used assignment operator = and arithmetic operator + for addition and concatenation (joining the strings together).
These are the combination of values, operators, and variables. They are used to compute the value.
sum = operand1 + operand2; is the expression used in the code.
We use them to name variables in a program. They follow certain rules:
- Identifiers must start with a letter, dollar sign ($), or underscore (_).
- Identifiers only consist of letters, numbers, dollar sign ($), and underscore (_).
- An identifier cannot be a keyword.
It is clear in the above example that the comments are never interpreted by the browser.
Hope the information provided was useful to you. Drop your feedback and queries below in the comment section.