JavaScript Syntax
Java script statements are separated by semicolons (;)
Ex:
var x = 2; var y = 3; var z = x + y;
the values (fixed) are also known as literals are written directly instead of putting them in a qoutes
20.2
03
string are written as
"Google"
"Blackfacers"
Variables can be assigned values using = operator :
var x;
x=50;
Arithmetic operators :
(5*2)+5
The values can be of string type can also be joined using operator + like
"Black" + " " + "facers"
Blackfacers will be the output.
Java script comments :
Code after double slashes // or between /* and */ is treated as a comment.
Javascript program ex:
var x = 10;
var y =5;
var z = x + y;
document.getElementById("sample").innerHTML =
z;
JavaScript Code Blocks :
JavaScript statements can be grouped together in code blocks, inside curly brackets {...}.function myFunction()
{
document.getElementById("demo").innerHTML = "Hello CODERS.";
document.getElementById("sample").innerHTML = "How are you?";
}
Here function is a keyword.
No comments:
Post a Comment