Skip to content
Mak Sò edited this page Apr 7, 2015 · 2 revisions

Object prototypes

  • concatElements([{key1:value1},{key2:value2},{key3:value3}])

    Concat more Objects in a single Object.git tag

    Object().concatElements([{key1:'value1'},{key2:'value2'},{key3:'value3'}])

    result

    {key1:"value1",key2:"value2",key3:"value3"}

  • generator([key,value,key2,value2,key3,value3.....])

    Generate Objects from an array

    Object().generator(["key1","value1","key2",{subkey1:"subvalue1",subkey2:"subvalue2"},"key3",["subvalue1","subvalue2"]])

    result

    {key1:"value1",key2:{subkey1:"subvalue1",subkey2:"subvalue2"},key3:["subvalue1","subvalue2"]}

  • lengthObject

    Count elements

    var a = {key1:"value1",key2:"value2",key3:"value3",key4:"value4",key5:"value5"};

    a.length()

    result

    5

  • splitElements

    Split element in an array of single elements

    var a = {key1:"value1",key2:"value2",key3:"value3"};

    a.splitElements()

    result

    [{key1:'value1'},{key2:'value2'},{key3:'value3'}]

  • toArray

    Generate an array with object values

    var o = {key1:"value1",key2:{subkey1:"subvalue1",subkey2:"subvalue2"},key3:["subvalue1","subvalue2"]};

    o.toArray();

    result

    ["value1",{subkey1:"subvalue1",subkey2:"subvalue2"},["subvalue1","subvalue2"]]

  • getValues(["key1","key2"....,"keyN"])

    Get specific values (only accept an ARRAY as search params)

    var o = {key1:"value1",key2:{subkey1:"subvalue1",subkey2:"subvalue2"},key3:["subvalue1","subvalue2"]};

    o.getValues(["key1","key3"]);

    result

    ["value1",["subvalue1","subvalue2"]]