Is there a way to define arrays and objects literally (i.e. assign all values in one go, inline)?

Is there something comprable to this var myObj = {city: "NY", city:"LA"} or ["NY", "LA"]?

The Javascript that is built in to Unity doesn't support the JSON-style freeform objects. This is because it's not really Javascript, it's actually just a Javascript-like syntax laid on top of the Mono (.Net) engine.

This means that the types and classes available to you are basically (for the most part) the same as you have in C#.

So, there are a number of different types of container you can use to store data. You can read a whole lot about them at this page on the Unity Wiki:

Which Kind Of Array Or Collection Should I Use?

Now, specifically for your question - declaring and defining the values of an array inline - this is possible in Javascript.

For built-in arrays, you can do it javascript like this:

var myInts : int[] = [ 1,2,3,4,5 ];
var myStrings : String[] = [ "apple", "bear", "cloud", "diamond", "egg" ];

And in C# it's very similar:

int[] myInts = { 1, 2, 3, 4, 5 };
string[] myStrings = { "apple", "bear", "cloud", "diamond", "egg" };

If you want to use more flexible arrays, you can use the Unity's Javascript Array class, and it's possible to specify the values inline by passing in a built-in array as the parameter when you create it, like this:

var myArray = new Array( [1,2,3,4,5] );
// or
var myArray = new Array(  [ "apple", "bear", "cloud" ] );

Or in C#, with an ArrayList (which is much the same thing)

ArrayList myArrayList = new ArrayList(  { 1, 2, 3, 4, 5 } );
// or
ArrayList myArrayList = new ArrayList(  { "apple", "bear", "cloud" } );

Now, if you really need a name-value pair data structure (eg, a Hashtable in either language, or a Dictionary is often a better choice in C#), I don't think there's a way to declare those inline. You basically have to create the object, and then add the name-value pairs line by line. For example hashtables in:

Javascript:

var myHashtable = new Hashtable();
myHashtable.Add( "apples", 8);
myHashtable.Add( "bananas", 6);
myHashtable.Add( "cakes", 3);
myHashtable.Add( "donuts", 20);
myHashtable.Add( "eggs", 12);

or C#:

Hashtable myHashtable = new Hashtable();
myHashtable.Add( "apples", 8);
myHashtable.Add( "bananas", 6);
myHashtable.Add( "cakes", 3);
myHashtable.Add( "donuts", 20);
myHashtable.Add( "eggs", 12);

Hope this helps!

Here’s how I create a (Javascript) Hashtable with values directly in the same line (without the need for Add())

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

Enjoy!

I’d like to add the following syntax for Generic Lists, similarly-looking to initialising the Javascript Array class:

var cth : List.<int> = new List.<int>( [5,40,45,49,53,56,59,62,65,68,70,72,74,76,78,80]);

As far as I know, Unity’s .NET variation supports all versions of initializers. So you would do better on this page: Object and Collection Initializers - C# Programming Guide | Microsoft Learn