button onclick event example javascript

Here is the example of button click Example javascipt

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

<p id="demo"></p>
function myFun()

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
function myfun(p,p1)
return p * p1;


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>
var per={name:"bipin",sex:"male",age:"20"}

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


javascript array

Javascript array declare in square brackets and array ithem are seperated by commas

Here is Example of array in javascript

<p id="test"> </p>

var car=["honda","maruti","tata"];


0utput will get honda..

How can add value to variable

we can use += operater to add a value to varable

For example

<p id="test">  </p>


var a;




How can concatenate String in javascript

+ operator used for concatenate string in Javascript

We can also use += operator for concatenate string

Example like

var a,b,c;
c= a+ " " + b;

what is Value = undefined in javascript

a variable declare a value not defind that is called undefind

For Example
<p id="test">
Var a;



Javascript Comment

There are two type comment in javascipt 

one is single line comment

other one is multi line comment



How Can Assigning value in javascript

How Can Assigning value in javascript

We can assign value in javascript in = sign

Here is the Example of code

<p id="test"></p>

var a,b

Output will be 20 ...

Simple Example of Javascript

<!DOCTYPE html>

<h1>Simple Example of javascript</h1>

<p id="demo">Test</p>

<button type="button" onclick='document.getElementById("demo").innerHTML = "Hello JavaScript!"'>Click Me!</button>


it will display out

Simple Example of javascript

Hello JavaScript!

What is javascript

JavaScript is programming language of html and Web. JavaScript  is dynamic and high level and interpreted programming language also it easy to study for learners