button onclick event example javascript

Here is the example of button click Example javascipt

<button onclick="myFun()">Click me</button>

<p id="demo"></p>
<script>
function myFun()
{
document.getElementById("demo").innerHTML="Test";
}
</script>

Javascript function

A JavaScript function is a block of code designed to perform a particular task.
A JavaScript function is executed when "something" calls it

Here is Example Of javascript function
<script>
function myfun(p,p1)
{
return p * p1;
}
document.getElementById("test").innerHTML=myfun(4,1);

</script>

Javascript Objects

JavaScript objects are written with curly braces.Object properties are written as name:value pairs, separated by commas.

Here is Example of object

<p id=""></p>
<script>
var per={name:"bipin",sex:"male",age:"20"}

document.getelementById("test").innerHTML=per.name +""+ per.sex+"";


</script>