parsed.org

Tips by tag: array

JSON By Example by http://ssttoo.myopenid.com/ on Mar 22, 2007 11:37 AM

JSON is an acronym for JavaScript Object Notation.

Objects

To create an object in JavaScript you can do:

var myobj = new Object();
myobj.prop = 1;

Using JSON you'd do:

var myobj = {prop:1};

Arrays

To create a new array you can do:

var a = new Array();
a[a.length] = 1;
a[a.length] = 2;

or using JSON:

var a = [1, 2];
arrayjavascriptjsonliteralobject
Order By Array Subscript by cygnus on Jan 12, 2005 10:25 AM

It is possible to order by an array element as follows:

SELECT * FROM (SELECT ARRAY[1, 2, 3] AS foo) sub ORDER BY foo[1];
arrayobscurepostgresqlsqlsyntax
Processing An Array by xinu on Apr 02, 2008 12:34 AM

In Perl you may have an array you'd like to iterate over. This would work:

for $line (@array) {
    print "line: $line\n";
}

Or you could use this abbreviated method with map():

print map ("line: $_\n") @array;
arraymapperlprint
RSS