1)
<html>
<head>
</head>
<body>
<script type="text/javascript">
document.write("Hello World");
</script>
</body>
</html>
2) Comments
// Single line
/*
Multiline comment
*/
3) Var is Variable
4) / (Backslash is used to escape)
5)Functions
<script type="text/javascript">
function funky () {
alert("ouch");
}
funky();
</script>
6) Functions with button click in a form
<script type="text/javascript">
function funky () {
alert("ouch");
}
</script>
<form>
<input type="button" value="touch me" onclick="funky()">
</form>
7) Functions with parameters
<script type="text/javascript">
function meatball(x) {
alert("Hello"+ x);
}
meatball("Karthik");
meatball("java");
</script>
8)Functions Passing multiple parameters
<script type="text/javascript>
function apples(one,two)
{
document.write(one+"is better than "+two+ "<br/>");
}
apples("karthik","vijay");
</script>
9)
<script type="text/javascript>
function tooeasy()
{
return "gametime";
}
document.write(tooeasy());
</script>
10)
<script type="text/javascript>
function addnumbers(a,b)
{
var c=a+b;
return c;
}
document.write(addnumbers(3,6));
</script>
11)Calling functions from different functions
<script type="text/javascript>
function doFirst()
{
document.write("I am First");
}
function doSecond()
{
document.write("I am Second");
}
function start() {
doFirst();
doSecond();
}
start();
</script>
<html>
<head>
</head>
<body>
<script type="text/javascript">
document.write("Hello World");
</script>
</body>
</html>
2) Comments
// Single line
/*
Multiline comment
*/
3) Var is Variable
4) / (Backslash is used to escape)
5)Functions
<script type="text/javascript">
function funky () {
alert("ouch");
}
funky();
</script>
6) Functions with button click in a form
<script type="text/javascript">
function funky () {
alert("ouch");
}
</script>
<form>
<input type="button" value="touch me" onclick="funky()">
</form>
7) Functions with parameters
<script type="text/javascript">
function meatball(x) {
alert("Hello"+ x);
}
meatball("Karthik");
meatball("java");
</script>
8)Functions Passing multiple parameters
<script type="text/javascript>
function apples(one,two)
{
document.write(one+"is better than "+two+ "<br/>");
}
apples("karthik","vijay");
</script>
9)
<script type="text/javascript>
function tooeasy()
{
return "gametime";
}
document.write(tooeasy());
</script>
10)
<script type="text/javascript>
function addnumbers(a,b)
{
var c=a+b;
return c;
}
document.write(addnumbers(3,6));
</script>
11)Calling functions from different functions
<script type="text/javascript>
function doFirst()
{
document.write("I am First");
}
function doSecond()
{
document.write("I am Second");
}
function start() {
doFirst();
doSecond();
}
start();
</script>