Subj : Function.toString - Silly Idea To : netscape.public.mozilla.jseng From : Baconbutty Date : Fri Aug 05 2005 10:28 am Hello I am a Javascript hobby user, rather than engineer, and I apologise if what follows is perceived as silly or ignorant technique, but I have used it on occasion, and I was interested to know if anyone else had thought of this, particularly as it works for me in the JScript engine (sorry for mentioning this), but not the Mozilla Javascript engine. As a hobby user (with no time to learn other languages), I have found that Javascript in the Browser is a great environment to write applications for use at my work (for instance I have a personal knowledge base system running 1MB of Javascript). On occasion I have wanted to store certain text resources, to use with my applications. I could store these resources in a String, but that would mean first escaping characters, to enable them to be used in a string literal. The second alternative was to store the resources in a hidden element within the web page, which is fine. The third was to load them from an external text file. A further idea I has was this. If I call toString() on a function reference in the JScript engine, it will include all of the comments originally contained within the JS code, including /* */ comments. My idea was to use functions as stores thus:- function myDataStore() { /* Here is some free Text in my store Even some should I need it for parsing later */ } I could then access this using:- myDataStore.toString() and extract the test using RegExp or other like methods. However, unlike the JScript engine, I have found that the Mozilla engine strips out comments in toString(). This idea probably breaks all models and conventions, but it is quick and dirty, and does the job on occasion. I wondered whether anyone had any thoughts on this, or just distant laughter?! Julian .