Can't find 'Prototype' syntax in JavaScript Bible'

S

SmallPaul

'JavaScript Bible' v6 by Danny Goodman doesn't seem to describe the
snytax used in Prototype.js. Namely, I could not find discussion of
'Object.extend' and the ':' feature (e.g., 'toColorPart:'), as in:

Object.extend(Number.prototype, {
toColorPart: function() {
var digits = this.toString(16);
if (this < 16) return '0' + digits;
return digits;
},

Similarly (or perhaps, not so similar), what this is about:

var Try = {
these: function() {
....
}
}

Can someone please tell me where to find this in the book, or if it's
not covered, where I can read up on this syntax.

Thanks
- Paul
 
D

David Mark

'JavaScript Bible' v6 by Danny Goodman doesn't seem to describe the
snytax used in Prototype.js.  Namely, I could not find discussion of

Why would it? Prototype is a library.
'Object.extend' and the ':' feature (e.g., 'toColorPart:'), as in:

The ": feature" is part of the object literal syntax. That should be
in any "JavaScript Bible."

The Object.extend method is silly. It was clearly dreamed up by a
person who didn't understand the inheritance features of the language.
Object.extend(Number.prototype, {
  toColorPart: function() {
    var digits = this.toString(16);
    if (this < 16) return '0' + digits;
    return digits;
  },

Similarly (or perhaps, not so similar), what this is about:

var Try = {
  these: function() {
   ....
  }

}

I am not sure. It looks like a wrapper for try/catch.
Can someone please tell me where to find this in the book, or if it's
not covered, where I can read up on this syntax.

Try a Prototype newsgroup if you feel you really want to use that
thing. You are really better off without it.
 
G

Gregor Kofler

SmallPaul meinte:
'JavaScript Bible' v6 by Danny Goodman doesn't seem to describe the
snytax used in Prototype.js. Namely, I could not find discussion of
'Object.extend' and the ':' feature (e.g., 'toColorPart:'), as in:

Object.extend(Number.prototype, {
toColorPart: function() {
var digits = this.toString(16);
if (this < 16) return '0' + digits;
return digits;
},

Similarly (or perhaps, not so similar), what this is about:

var Try = {
these: function() {
....
}
}

Can someone please tell me where to find this in the book, or if it's
not covered, where I can read up on this syntax.

That's JS object notation. There are plenty of ressources on that on the
web. One randomly picked:
<http://msdn2.microsoft.com/en-us/library/bb299886.aspx#intro_to_json_topic2>

Gregor
 
T

Thomas 'PointedEars' Lahn

SmallPaul said:
'JavaScript Bible' v6 by Danny Goodman doesn't seem to describe the
snytax used in Prototype.js.

That's too bad because both have been written by people who don't know
J(ava)Script.


PointedEars
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top