Call variable in function

Discussion in 'JavaScript' started by 2mk_atspace, Feb 29, 2008.

  1. #1
    Is there any way to make variable that declare inside function can be call out side function ?
     
    2mk_atspace, Feb 29, 2008 IP
  2. mintoj

    mintoj Peon

    Messages:
    317
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can return the value of a variable from your function call

    function hello()
    {
    var myname;
    myname = "Jack";
    return "hello I'm " + myname;
    }

    OR you could declare a global var


    var myname = "Jack";

    function hello()
    {
    return "hello I'm " + myname;
    }
     
    mintoj, Feb 29, 2008 IP
  3. 2mk_atspace

    2mk_atspace Well-Known Member

    Messages:
    317
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #3
    how about if i want return multiple value ?
     
    2mk_atspace, Mar 4, 2008 IP
  4. in2clearsky

    in2clearsky Peon

    Messages:
    121
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0