473,410 Members | 1,857 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

language help

I was reading the code of Bookburro greasemonkey user javascript. I
don't understand some of the language features the author has used.

For example, in the following code,

var handlers = [
{ name: 'Abebooks.com', id: 'abebooks', hostname: /\babebooks.com$/i,
getISBN: /(?:isbn|bi)=([0-9X]{10})(&|\?|$)/i,
bookURL:
'http://www.abebooks.com/servlet/SearchResults?isbn=%s&pid='+
abebooks_pid +'&aid='+ abebooks_aid,
ajaxPrice: /<span class="price">\D*(\$[^<]*)/i },
{ name: 'Ad Libris', id: 'alse', hostname: /\badlibris\.se$/i,
bookURL: 'http://www.adlibris.se/shop/product.asp?isbn=%s',
ajaxPrice: function( html, http )
{
if( html.match( 'Ingen titel med detta ISBN finns hos AdLibris.'
) )
return '';
return SEK( html.match( '<span class="price">([^<]*)<' )[1] );
} },
......

];

1. var handlers = [ { .. }, ..., {... } ];
what does this mean? Is 'handlers' an array?

2. { name: 'xxx' , id: 'yyy' , ... }
Is this an associative array?

I have not seen this kind of js code before. Can any one let me know
what they are or point me to any good reference books or websites?

Thanks a lot.

Dec 30 '05 #1
2 1104

Nan Li wrote:
1. var handlers = [ { .. }, ..., {... } ];
what does this mean? Is 'handlers' an array?
Yes, that is a shorthand for creating an array. In this case, it
appears handlers is an array of 1..n objects.
2. { name: 'xxx' , id: 'yyy' , ... }
Is this an associative array?


The above expression is the syntax for creating an object literal which

is defined in ECMAScript v3. It allows you to create an object and
specify its properties. It consists of a comma-separated list of
colon-separated property/value pairs. So in your above expression, you

have an object with properties "name" and "id" whose corresponding
value is "xxx" and "yyy".

Dec 30 '05 #2
On 2005-12-30, Nan Li <na******@gmail.com> wrote:
1. var handlers = [ { .. }, ..., {... } ];
what does this mean? Is 'handlers' an array?
yes.
2. { name: 'xxx' , id: 'yyy' , ... }
Is this an associative array?
no, an object.
which behaves somewhat like an associative array does in other languages
but also somewhat differently.
I have not seen this kind of js code before. Can any one let me know
what they are or point me to any good reference books or websites?


Bye.
Jasen
Dec 31 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Jon Slaughter | last post by:
I'm trying to get into web development for creating a professional web site and I'm confused on which language I should use. I've read some comparisons between the major languages and I was...
26
by: nospam | last post by:
Just wondering, What do you think the difference in performance would be between (1.) Compiled C# (2.) Compiled C++ (3.) and Assembly Language And how would the mix be if some if any of...
6
by: Wiktor Zychla | last post by:
I've downloaded the polish language pack for .Net Framework 1.1 and I've installed it. Now I expect to see any exception messages in my native language but I still get english texts in exception...
41
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based...
0
by: sastwhc | last post by:
sastwhc wrote: > *Hi all > I try change language client side programatically.In my case farsi a > Right to Left Language,the curser direction changed by dir=rtl TAG > changed to correct direction...
2
by: Chance Ginger | last post by:
I am rather new at Python so I want to get it right. What I am doing is writing a rather large application with plenty of places that strings will be used. Most of the strings involve statements of...
25
by: Dave | last post by:
I want to spend two minutes on my soapbox. I love C#. I am so productive in it it's ridiculous. But it's so easy to write code that uses poor design principles. Example: just making...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
12
by: Tony Belding | last post by:
I'm interested in using an off-the-shelf interpreted language as a user-accessible scripting language for a MUCK. I'm just not sure if I can find one that does everything I need. The MUCK must be...
9
by: aleplgr | last post by:
Hi! I'm trying to let the end-user select the language of the menues I'm showing him. To do that I've got this Selector class that shows the end user a combo box, a label and a button. In the combo...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.