Successfully reported this slideshow.
Disclaimer: This presentation is prepared by trainees of
baabtra as a part of mentoring program. This is not official
docu...
Typing Speed
Week

Target Achieved

1

40

21

2

40

23

3

40

27
Jobs Applied
Week

Company

Designation

Applied Date

Current Status

1

Advent
software

Sr. Application Engineer

26-8-...
Functions in Javascript
Muhammed Noufal V T
muhammednoufalvt@gmail.c
om
www.facebook.com/vtnoufa
lvt
twitter.com/noufalurn...
•

What is Functions defined)
A group of statements that is put together (or

once and then can be used (by reference) rep...
Advantages of Functions
• Number of lines of code is reduced
• Code becomes easier to read &
understand
• Code becomes eas...
Example
•

<html>
<head>
<title>Assignment-2</title>
</head>
<script>
function date()
{
var d=new Date();
document.write(d...
Function Defnitions
•
•

•

Format of a function definition
function function-name( parameter-list )
{
declarations and st...
Function Parameters
• Facility to pass different parameters
while calling a function
• Passed parameters can be captured
i...
• <html>

Example

<head>
<script type="text/javascript">
function say(name, age)
{
alert( "I am" + name + age + " years o...
Local and Global variable
• A variable declared (using var) within a
JavaScript function becomes LOCAL and can
only be acc...
Contact Us
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550

Start up Vil...
Functions in javascript
Upcoming SlideShare
Loading in …5
×

Functions in javascript

662 views

Published on

Functions in javascript

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Functions in javascript

  1. 1. Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring Partner Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
  2. 2. Typing Speed Week Target Achieved 1 40 21 2 40 23 3 40 27
  3. 3. Jobs Applied Week Company Designation Applied Date Current Status 1 Advent software Sr. Application Engineer 26-8-2013 Short listed 2 Alcatel-lucent Software Engineer 28-8-2013 Waiting 3
  4. 4. Functions in Javascript Muhammed Noufal V T muhammednoufalvt@gmail.c om www.facebook.com/vtnoufa lvt twitter.com/noufalurnappy in.linkedin.com/pub/muham med-noufal 9744003056
  5. 5. • What is Functions defined) A group of statements that is put together (or once and then can be used (by reference) repeatedly on a Web page • Also known as subprogram, procedure, subroutine • A function is written as a code block (inside curly { } braces), preceded by the function keyword • Syntax js function – function functionname() { some code to be executed } – alert("message") – confirm("message") – prompt("message")
  6. 6. Advantages of Functions • Number of lines of code is reduced • Code becomes easier to read & understand • Code becomes easier to maintain as changes need to be made only at a single location instead multiple
  7. 7. Example • <html> <head> <title>Assignment-2</title> </head> <script> function date() { var d=new Date(); document.write(d); } </script> <body> <p>Press the button to show current date & time... </p> <input type="button" onclick="date()" value="Show date"> </body> </html>
  8. 8. Function Defnitions • • • Format of a function definition function function-name( parameter-list ) { declarations and statements } – Function name any valid identifier – Parameter list names of variables that will receive arguments • Must have same number as function call • May be empty – Declarations and statements • Function body (“block” of code) Return statement – Optional , can return either nothing, or a value – This is required if you want to return a value from a function
  9. 9. Function Parameters • Facility to pass different parameters while calling a function • Passed parameters can be captured inside the function and any manipulation can be done over those parameters • A function can take multiple parameters separated by comma. • Parameters define the interface between the function and the rest of
  10. 10. • <html> Example <head> <script type="text/javascript"> function say(name, age) { alert( "I am" + name + age + " years old."); } </script> </head> <body> <p>Click the following button to Know about my self</p> <form> <input type="button" onclick="say('Baabtra', 2)" value="Myself"> </form> </body> </html>
  11. 11. Local and Global variable • A variable declared (using var) within a JavaScript function becomes LOCAL and can only be accessed from within that function
  12. 12. Contact Us Emarald Mall (Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Start up Village Eranakulam, Kerala, India. Email: info@baabtra.com NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550

×