JavaScript Tutorial/Language Basics/Semicolon — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 08:24, 26 мая 2010
End-of-line semicolons are optional.
JavaScript allows the developer to decide whether or not to end a line with a semicolon.
If the semicolon is not provided, JavaScript considers the end of the line as the end of the statement.
var test1 = "red"
var test2 = "blue";
The Semicolon
JavaScript executes your code accordingly even if you forget a semicolon at the end of the line.
You must use a semicolon to separate the two pieces of code when putting two independent pieces of code on one line.
<html>
<body>
<SCRIPT LANGUAGE="JavaScript">
<!--
// Declare 2 numeric variables on the same line
var varA = 5; var varB = 0.06;
;
document.write(varA*varB);
-->
</SCRIPT>
</body>
</html>