# JavaScript Functions

**URL:** https://forum.kirupa.com/t/javascript-functions/332043
**Category:** programming
**Created:** [January 8, 2014, 9:29am UTC](https://forum.kirupa.com/t/javascript-functions/332043 "2014-01-08T09:29:45Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![parkhyasolution](https://avatars.discourse-cdn.com/v4/letter/p/c5a1d2/32.png) [@parkhyasolution](https://forum.kirupa.com/u/parkhyasolution)
#### Post date: [January 8, 2014, 9:29am UTC](https://forum.kirupa.com/t/javascript-functions/332043/1 "2014-01-08T09:29:45Z")

</div>

A function is a block of code that will be executed when “someone” calls it:  
\<!DOCTYPE html\>  
\<html\>  
\<head\>  
\<script\>  
function myFunction()  
{  
alert(“Hello World!”);  
}  
\</script\>  
\</head\>

\<body\>  
\<button onclick=“myFunction()”\>Try it\</button\>  
\</body\>  
\</html\>  
A function is written as a code block (inside curly { } braces), preceded by the **function** keyword:  
function _functionname_()  
{  
_some code to be executed_  
}  
[software development in Indore , [URL=“http://www.parkhya.com/Pages/Training.aspx”]Java Traning in indore ,[URL=“http://www.parkhya.com/”]MCA Training in indore ](http://www.parkhya.com/)  
[TABLE]  
[TR]  
[TD][/TD]  
[/TR]  
[/TABLE]

[TABLE]  
[TR]  
[TD][/TD]  
[/TR]  
[/TABLE]  
[TABLE]  
[TR]  
[TD][/TD]  
[/TR]  
[/TABLE]
