Get Array Name

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sunny

    Get Array Name

    Hi,

    Do anyone, Knows, How to get array Name?

    Like If I have a array:
    abc & I would like to get the name abc, How can I do that.
    I am trying to set abc.name but its not working.

    I have to get the array name, so that I can change them dynamically.
    What to do?
  • Conrad Lender

    #2
    Re: Get Array Name

    On 2008-10-17 18:38, Sunny wrote:
    Do anyone, Knows, How to get array Name?
    >
    Like If I have a array:
    abc & I would like to get the name abc, How can I do that.
    I am trying to set abc.name but its not working.
    >
    I have to get the array name, so that I can change them dynamically.
    What are you talking about? Arrays don't have names.

    (...that is, unless you assign them a .name property yourself, which
    does in fact "work")

    If you're asking how to find out the name of a variable that holds a
    reference to an array, you're probably doing something else wrong. If
    that's not what you were asking, maybe you should give a little more
    sample code than "abc".


    - Conrad

    Comment

    • Stevo

      #3
      Re: Get Array Name

      Sunny wrote:
      Hi,
      >
      Do anyone, Knows, How to get array Name?
      >
      Like If I have a array:
      abc & I would like to get the name abc, How can I do that.
      I am trying to set abc.name but its not working.
      You should show the code you're using which isn't working.

      Assuming the code you have that wants to "do stuff" with an array takes
      that array as a parameter, then why not make the caller pass in the
      array name as a string. Example:

      var myarray=[];
      function doStuffTo(somea rrayname)
      {
      window[somearrayname][0]="cool array[0] string";
      }

      doStuffTo("myar ray");
      I have to get the array name, so that I can change them dynamically.
      What to do?
      Can you explain more about what you mean by changing "them" dynamically.

      Comment

      • Erwin Moller

        #4
        Re: Get Array Name

        Sunny schreef:
        Hi,
        >
        Do anyone, Knows, How to get array Name?
        >
        Like If I have a array:
        abc & I would like to get the name abc, How can I do that.
        I am trying to set abc.name but its not working.
        >
        I have to get the array name, so that I can change them dynamically.
        What to do?
        Hi,

        What do you mean excactly?

        var myArr = [1,2,3];
        var meToo = meArr;
        hereIsAnArr(myA rr);

        function hereIsMyArr(som eArr){
        // do you want to find the name of the arr here?
        // Then what name? myArr or meToo?
        }

        The 'name' of an array is just a variablename available in a certain
        scope that POINTS TO (=reference) an array.
        (I hope I phrased that right.)

        Maybe I misunderstand what you mean. If so, please clarify.

        Regards,
        Erwin Moller


        --
        "There are two ways of constructing a software design: One way is to
        make it so simple that there are obviously no deficiencies, and the
        other way is to make it so complicated that there are no obvious
        deficiencies. The first method is far more difficult."
        -- C.A.R. Hoare

        Comment

        • Erwin Moller

          #5
          Re: Get Array Name

          Sunny schreef:
          Hi,
          >
          Do anyone, Knows, How to get array Name?
          >
          Like If I have a array:
          abc & I would like to get the name abc, How can I do that.
          I am trying to set abc.name but its not working.
          >
          I have to get the array name, so that I can change them dynamically.
          What to do?

          Hi,

          What do you mean excactly?

          var myArr = [1,2,3];
          var meToo = myArr;
          hereIsAnArr(myA rr);

          function hereIsMyArr(som eArr){
          // do you want to find the name of the arr here?
          // Then what name? myArr or meToo?
          }

          The 'name' of an array is just a variablename available in a certain
          scope that POINTS TO (=reference) an array.
          (I hope I phrased that right.)

          Maybe I misunderstand what you mean. If so, please clarify.

          Regards,
          Erwin Moller


          --
          "There are two ways of constructing a software design: One way is to
          make it so simple that there are obviously no deficiencies, and the
          other way is to make it so complicated that there are no obvious
          deficiencies. The first method is far more difficult."
          -- C.A.R. Hoare

          Comment

          • Erwin Moller

            #6
            Re: Get Array Name

            Sunny schreef:
            Hi,
            >
            Do anyone, Knows, How to get array Name?
            >
            Like If I have a array:
            abc & I would like to get the name abc, How can I do that.
            I am trying to set abc.name but its not working.
            >
            I have to get the array name, so that I can change them dynamically.
            What to do?
            [I posted a wrong version first, I hope the cancelation worked. :P]

            Hi,

            What do you mean excactly?

            var myArr = [1,2,3];
            var meToo = myArr;
            hereIsAnArr(myA rr);

            function hereIsAnArr(som eArr){
            // do you want to find the name of the arr here?
            // Then what name? myArr or meToo?
            }

            The 'name' of an array is just a variablename available in a certain
            scope that POINTS TO (=reference) an array.
            (I hope I phrased that right.)

            Maybe I misunderstand what you mean. If so, please clarify.

            Regards,
            Erwin Moller




            --
            "There are two ways of constructing a software design: One way is to
            make it so simple that there are obviously no deficiencies, and the
            other way is to make it so complicated that there are no obvious
            deficiencies. The first method is far more difficult."
            -- C.A.R. Hoare

            Comment

            Working...