473,806 Members | 2,879 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What does Class.create() in 'Prototype.js' do?

Prototype.js is here: http://prototype.conio.net/
Aug 16 '05 #1
5 9995
Kunle Odutola said the following on 8/16/2005 5:12 AM:
Prototype.js is here: http://prototype.conio.net/


And why do I want Prototype.js?

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Aug 16 '05 #2

"Randy Webb" <Hi************ @aol.com> wrote in message
news:nJ******** ************@co mcast.com...
Kunle Odutola said the following on 8/16/2005 5:12 AM:
Prototype.js is here: http://prototype.conio.net/


And why do I want Prototype.js?


To see the source to Class.create().

Anyway, here it is:

var Class = {
create: function() {
return function() {
this.initialize .apply(this, arguments);
}
}
}

Does it simply create a constructor function that requires and will call a
method 'initialize' on the object it creates passing it all arguments?
Aug 16 '05 #3
> Does it simply create a constructor function that requires and will call a
method 'initialize' on the object it creates passing it all arguments?


I'm a javascript novice but it sure looks like this is correct. It
seems like Class.create() is designed to allow end users to create
objects with the usual syntax that then call their own initialize
methods.

My question is why do this instead of simply having each constructor
call its own init method? Since prototype.js looks like it is
beautifully coded, I'm sure there is a good reason...anyone ? (a guess
is that this helps avoid global namespace collisions)

An excellent reference:
http://www.brockman.se/writing/metho...nces.html.utf8

Aug 17 '05 #4
In case you're still looking for documentation for prototype.js, I'm
trying to keep something at:
http://www.sergiopereira.com/articles/prototype.js.html

I hope it can be useful while no official documentation is made
available

Kunle Odutola wrote:
Prototype.js is here: http://prototype.conio.net/


Aug 22 '05 #5
Very helpful, thanks!

Aug 22 '05 #6

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

Similar topics

28
3312
by: David MacQuigg | last post by:
I'm concerned that with all the focus on obj$func binding, &closures, and other not-so-pretty details of Prothon, that we are missing what is really good - the simplification of classes. There are a number of aspects to this simplification, but for me the unification of methods and functions is the biggest benefit. All methods look like functions (which students already understand). Prototypes (classes) look like modules. This will...
7
3564
by: Michele Simionato | last post by:
So far, I have not installed Prothon, nor I have experience with Io, Self or other prototype-based languages. Still, from the discussion on the mailing list, I have got the strong impression that you do not actually need to fork Python in order to implement prototypes. It seems to me that Python metaclasses + descriptors are more than powerful enough to implementing prototypes in pure Python. I wrote a module that implements part of what...
5
6541
by: Da Costa Gomez | last post by:
Hi, I was wondering whether someone could shed some light on the following. Using inheritance in Java one can override a function f() (or is it overload?) in the child and then do: public f() { super.f(); ... } in the child to first execute the parent stuff to be followed by the
121
10200
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode support IDEs are DreamWeaver 8 and Zend PHP Studio. DreamWeaver provides full support for Unicode. However, DreamWeaver is a web editor rather than a PHP IDE. It only supports basic IntelliSense (or code completion) and doesn't have anything...
2
6079
by: rhamlin | last post by:
I'm working on a class. When instantiating I pass the variable name referencing the class (vw) and the page object where the class will display (view). In this class I create a DIV. I also place a DIV inside the first which will act as a button and when clicked will run code that's also inside the class. To create the button DIV I use the addBtn function inside the class.
9
3104
by: pamelafluente | last post by:
Hi, I was "studying" the famous (public code) BusyBox. I see the instruction: var busyBox = new BusyBox as in var busyBox = new BusyBox("BusyBox1", "busyBox", 4, "gears_ani_", ".gif", 125, 147, 206)
4
6698
by: grizggg | last post by:
I have searched and not found an answer to this question. I ran upon the following statement in a *.cpp file in a member function: static const char * const pacz_HTMLContentTypeHeader = "Content-Type: text/html\r\n"; Why is the second const needed and what does it do? Thanks
3
1538
by: navneet.krg | last post by:
create a class myClass using prototype.js's Class.create() then create an object foo of that myClass then "object.constructor" will return "function Object() { }" should be myClass does prototype.js does not set the constructor property properly if i create the class using
4
3880
by: Ty | last post by:
Hello all, I am creating a web site with Visual Stuido 2008. I am trying to use a java script file to create a busybox for login from this page http://blogs.crsw.com/mark/articles/642.aspx. I am using a master page senerio. The erro I'm getting is 'busyBox' is not a member of 'ASP.login2_aspx'
0
9719
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9597
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10620
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10372
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10110
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6877
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5682
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3851
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.