network monitoring
Results 1 to 3 of 3

Thread: Java Script Populating 2D array thought prompt???

Threaded View

  1. #3
    miketaylor Guest
    I just noticed too, when i was trying to implement a 2D array into JS. It is Screwed. But here is a solution if you want to stick to multidimensional arrays: An Object.

    function Array2D() {
    function setArray(length) { // set an array inside the object
    this.elem=new Array();
    for(i=0;i<length;i++) {
    this.elem[i]=null;
    }
    }
    this.setArray=setArray;
    this.elem=null; // our array
    }

    With this little fella you can hide your intentions from the Evil Javascript Developers, and secretly make a 2D array:

    arr = new Array();
    arr[0] = new Array2D();
    arr[0].setArray(2);
    arr[0].elem[0] = "Hy, ";
    arr[0].elem[*] = "I'm ";
    arr[*] = new Array2D();
    arr[*].setArray(2);
    arr[*].elem[0] = "Da";
    arr[*].elem[*] = "vid!";

    alert(arr[0].elem[0] + arr[0].elem[*] + arr[*].elem[0] + arr[*].elem[*]); // this will say "Hy, I'm David!"

    *******************
    Last edited by DougN; 09-06-2012 at 03:47 PM.

Similar Threads

  1. Array of Hope
    By JayT in forum Programming
    Replies: 9
    Last Post: 03-25-2008, 03:49 PM
  2. Array Of Hope
    By JayT in forum Programming
    Replies: 3
    Last Post: 09-27-2007, 09:49 PM
  3. command prompt
    By Unregistered in forum Internet Privacy
    Replies: 1
    Last Post: 02-13-2005, 12:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts