server-side JavaScript: Example 3: Dictionary class

Discussion in 'Javascript' started by GVDC, Jun 28, 2008.

  1. GVDC

    GVDC Guest

    Example server-side JavaScript Web script, Dictionary class


    //Dictionary class, hash array unlimited length configurable speed/efficiency
    //
    printf("<html><body>");

    printf("<b>Creating dictionary</b><br\n>");

    var dictobj = new Dictionary(5); //dictionary class
    var dvname = "varnam0"; //dict var name

    var smplobj = new Object(); //create object
    smplobj.xx = "text1"; //add properties
    smplobj.yy = "text2";

    printf("<b>Storing object into dictionary</b><br\n>");
    printf("<br\n>");
    //put object into array
    dictobj.set(dvname,smplobj);

    printf("<b>Reading value stored in dictionary</b><br\n>");
    printf("value of " ,dvname, " property xx: [", dictobj.get(dvname).xx, "]<br\n>");
    printf("<br\n>");

    printf("<b>Changing property xx value to otherval567</b><br\n>");

    //values in dictionary are stored by reference, not copy
    //modifying value of object's property also changes value stored in dictionary
    smplobj.xx = "otherval567";

    printf("value of " ,dvname, " property xx after change: [", dictobj.get(dvname).xx, "]<br\n>");
    printf("<br\n>");


    printf("<b>Checking array (dictionary) length</b><br\n>");
    printf("array length: [", dictobj.len(), "]<br\n>");
    printf("<br\n>");

    printf("<b>Deleting value from array</b><br\n>");
    //erase value from dictionary
    dictobj.set(dvname,null);

    printf("array length after delete: [", dictobj.len(), "]<br\n>");


    printf("</body></html>");



    --
     
    GVDC, Jun 28, 2008
    #1
    1. Advertising

  2. GVDC wrote:
    > Example server-side JavaScript Web script, Dictionary class


    Example client-side JavaScript, complete Idiot "class":

    function Idiot()
    {
    var value = "GVDC";
    this.who = function() { return value; };
    }

    window.alert((new Idiot()).who());

    <http://jibbering.com/faq/>


    PointedEars
    --
    var bugRiddenCrashPronePieceOfJunk = (
    navigator.userAgent.indexOf('MSIE 5') != -1
    && navigator.userAgent.indexOf('Mac') != -1
    ) // Plone, register_function.js:16
     
    Thomas 'PointedEars' Lahn, Jun 28, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Qw==?=
    Replies:
    1
    Views:
    3,281
    Hermit Dave
    Jan 16, 2004
  2. Shawn Milo
    Replies:
    20
    Views:
    614
    Bruno Desthuilliers
    Mar 4, 2007
  3. GVDC
    Replies:
    0
    Views:
    402
  4. GVDC
    Replies:
    0
    Views:
    188
  5. GVDC
    Replies:
    0
    Views:
    150
Loading...

Share This Page