jslint doesn't like my syntax for conditional object creation

R

Richard Cornford

VK said:
A previous one... This time he got me. Damn his left
hook to the head with the Identifiers pre-processing...
But I reached him couple of times too, did you see?

You are deluding yourself.
:) joking


So I was right in my guess. Really you should always
spell the context of your question.

Just utterly mistaken about the consequences of there being no other
declaration of the variable.
No, it doesn't look ahead, it's even more funny as I see it. ...
<snip - more VK fiction>

But you don't "see it", except in your own head.
... . The most ridiculous mechanics I ever seen,
this is why it squeezed so hard into my mind.

Not because of all the crap you have in there to start with?
I guess
Brendan Eich knows why did they do this way (one of "durt
coding tolerance" things?)

It was much more likely designed to keep the implementation of the
function scoping units simple and quick.

Richard.
 
P

petermichaux

Richard said:
(e-mail address removed) wrote:

VK has a serious habit of posting fictions originating in
his deranged mind. That results in much effort being wasted correcting
him

No offense to VK, but probably many people don't understand JavaScript
all that well. It is not so usual compared to the C/C++/Java people
learn at school. (I vote for Ruby in browsers!)
Like all programming languages, javascript is completely logical,
consistent and predictable in its behaviour. That makes it entirely
possible to completely understand javascript, so long as you are capable
of rational thought.

....and have a good book to read. Much of this could be solved with a
good book. Where is the good book on JavaScript? I'm not talking about
a nitty gritty, line-by-line look at a JavaScript interpreter but and
intermediate/intermediate-advanced book on JavaScript. Something that
can come after JavaScript: The Definitive Guide 4th ed.

Peter
 
R

Richard Cornford

No offense to VK, but probably many people don't
understand JavaScript all that well.

But most people realise when they don't understand something that well.
VK is so mad that he actually thinks he is the only person with any real
understanding of javascript. That is why he goes blindly on repeating
the same nonsense, never listening to anyone repeatedly telling him he
is wrong. After all, why would I have to repeat that conditional
variable declarations did not exist in javascript if he was not utterly
convinced that I do not know what I am talking about? He didn't get that
idea from reading and understanding my posts, he can only believe that
as a result of assuming that anyone who doesn't agree with him must be
mistaken.

Also, bear in mind that VK claims to have been scripting browsers for
about 10 years. To have failed to understand even the basics in that
time is pretty poor, but superficial success over an extended period,
and avoiding contact with anyone who has a real understanding, obviously
can promote self delusion on his scale.
It is not so usual compared to the C/C++/Java people
learn at school. (I vote for Ruby in browsers!)

If all browser manufacturers implemented Ruby tomorrow we would be able
to use it in about 6 years time. So get used to javascript in browser
;-)
...and have a good book to read. Much of this could be solved
with a good book. Where is the good book on JavaScript?

If there were good books. If asked we have no choice but recommend the
least bad javascript book (JavaScript: The Definitive Guide, By David
Flanagan), and some of the rest are so bad that you would be worse off
reading them than not.
I'm not talking about a nitty gritty, line-by-line look
at a JavaScript interpreter but and
intermediate/intermediate-advanced book on JavaScript.

It is not an easy read, but ECMA 262 (3ed Ed.) would be my reading
recommendation if you want to understand the language. But you don't
learn about the interpreter(s) from that document as the language is
defined in terms of its required behaviour and the implementation then
left to the implementers.
Something that can come after JavaScript: The Definitive
Guide 4th ed.

In that case are you thinking about script design issues rather than
javascript as a programming language?

Richard.
 
P

petermichaux

(I vote for Ruby in browsers!)
If all browser manufacturers implemented Ruby tomorrow we would be able
to use it in about 6 years time. So get used to javascript in browser
;-)

I say they start working on it now! I'll be very happy in 6 years :D

It is not an easy read, but ECMA 262 (3ed Ed.) would be my reading
recommendation if you want to understand the language. But you don't
learn about the interpreter(s) from that document as the language is
defined in terms of its required behaviour and the implementation then
left to the implementers.

I'll take a closer look.

In that case are you thinking about script design issues rather than
javascript as a programming language?

One of each please.

Perhaps a book about JavaScript as an implementation of ECMA. This
would be a readable version of ECMA 262 (3rd Ed.) targeted to
JavaScript developers.

The other book would be about script design and modern professional
JavaScript (whatever that means.) Working with OOP in JavaScript,
simulated namespaces (eg. yahoo.js) and other stuff you use after you
get past JavaScript for just making tags like (untested)

<a href="http://www.example.com" onclick='alert("thanks for
clicking");'>

There is a lot of JavaScript info in books and on the internet that
slowed down my JavaScript beginnings. Definitely tarnishes the
language's appeal.

Peter
 
R

Richard Cornford

I say they start working on it now! I'll be very happy in
6 years :D

It is a Catch 22 situation; it won't be implement now because nobody
will be able to use it usefully for 6 years so there is no point making
the effort, but unless it is implemented now it won't even be being used
in 6 years. On the other hand javascript is a very capable language
(well beyond the usual perception of it) so there is no real need for an
(or another) alternative.

One of each please.

Perhaps a book about JavaScript as an implementation of ECMA.
This would be a readable version of ECMA 262 (3rd Ed.) targeted
to JavaScript developers.

If well done that might be a good idea.
The other book would be about script design and modern
professional JavaScript (whatever that means.)

It probably doesn't mean much. The majority of current commercial
practice is not up to much, and there are not many people actually
employed as professional javascript authors (and fewer who should be).
Working with OOP in JavaScript,

There is certainly a deficit in appreciation of how javascript's
prototype inheritance differs from class-based inheritance (and the
implications of those differences on how OO should be implemented).
simulated namespaces (eg. yahoo.js)

Simulated namespaces are a very questionable notion. In other language
the namespaces are resolved when the code is compiled. Javascript must
resolve those long property accessors each and every time they are used.
In addition, it is questionable whether the perceived namespace issue is
real to start with. I work on an application framework with a code base
of 60,000 lines of client-side javascript and don't see any problem with
naming collisions at all. If two objects are well named and share the
same name then they are doing the same task, so one of them is redundant
and should not be there. There just are not enough objects in that
system for namespaces to be an issue, and that is a very extreme system.

That will be true of any real-world implementation. You only need
namespaces if you are going to create a theoretically infinitely larger
system, but that is just not going to happen in real implementations.
The situation is not like making an enormous collection of
classes/packages available in Java, where any can be loaded from the
local hard disc, there is simply no sense in even attempting to download
any substantial mass of javascript to a web browser such that namespaces
are needed at runtime.
and other stuff you use after you
get past JavaScript for just making tags like (untested)

<a href="http://www.example.com" onclick='alert("thanks for
clicking");'>

Yuck! (bothering users with pointless stuff that gets in their way;
certainly a design decision that people need to learn to avoid.)
There is a lot of JavaScript info in books and on the
internet that slowed down my JavaScript beginnings.
Definitely tarnishes the language's appeal.

Bad books are a problem (Danny Goodman has a lot to answer for).

Richard.
 
P

petermichaux

Richard said:
There is certainly a deficit in appreciation of how javascript's
prototype inheritance differs from class-based inheritance (and the
implications of those differences on how OO should be implemented).

Isn't there a good chance that class based inheritance is in
JavaScript's future? I remember seeing Netscape JavaScript 3 Proposed
changes with classes and other stuff. Of course, we won't be able to
use it for six years.

Simulated namespaces are a very questionable notion. In other language
the namespaces are resolved when the code is compiled. Javascript must
resolve those long property accessors each and every time they are used.

So it would be better just to use a prefix to uniquify things?
Something like

YahooEvent.AddListener()

instead of

Yahoo.Event.addListener()

?

You work for Yahoo!, correct? What do you think about the use of pseudo
namespaces in that library (ie. the yahoo.js script)?

In addition, it is questionable whether the perceived namespace issue is
real to start with.

If Prototype.js used a pseudo namespace wouldn't that mean they would
have a smaller chance of breaking other JavaScript like for-in loops?
Maybe namespaces could protect unknowing programmers. Not that it is a
great argument but it is somewhat practical.

That will be true of any real-world implementation. You only need
namespaces if you are going to create a theoretically infinitely larger
system, but that is just not going to happen in real implementations.
The situation is not like making an enormous collection of
classes/packages available in Java, where any can be loaded from the
local hard disc, there is simply no sense in even attempting to download
any substantial mass of javascript to a web browser such that namespaces
are needed at runtime.

I suppose there will be a larger and larger base of libraries that
people can use in their projects. As the available bulk of libraries
increases there is a chance of a namespace between any two. That is
what I was thinking about.


-Peter
 
R

RobG

Richard Cornford wrote: [...]
In addition, it is questionable whether the perceived namespace issue is
real to start with.

If Prototype.js used a pseudo namespace wouldn't that mean they would
have a smaller chance of breaking other JavaScript like for-in loops?
Maybe namespaces could protect unknowing programmers. Not that it is a
great argument but it is somewhat practical.

That's not a good example. Prototype.js could create its own array
constructor (say called PTArray), then modify its prototype, leaving the
built-in Array alone. The author *chose* to modify the default
built-in object (well, its prototype).

Had programmers been given a choice of creating a PTArray or a standard
Array, they could look at the code and say "Hmm, no PTArray, let's
remove that from the library for this application".

If decent documentation was available, they could even make sure that
none of the other functions they've used need PTArray either.

[...]
 
R

Richard Cornford

Isn't there a good chance that class based inheritance is
in JavaScript's future? I remember seeing Netscape
JavaScript 3 Proposed changes with classes and other stuff.
Of course, we won't be able to use it for six years.

That is JavaScript(tm) 2 and, if ratified, will be ECMAScript 4th
edition. There will be no widespread implementation until it is ratified
(at least two years overdue at the moment) and it will not be practical
to use for 6 years after that.
So it would be better just to use a prefix to uniquify things?
Something like

YahooEvent.AddListener()

instead of

Yahoo.Event.addListener()

Better, but not by much. If the final object is given a name that says
something meaningful about what it actually does then a second object
with the same name should be doing the same job, and so not needed in
any system using the first.
You work for Yahoo!, correct?
No.

What do you think about the use of pseudo namespaces
in that library (ie. the yahoo.js script)?

Its use is a reason for not using yahoo's code in its original form.
If Prototype.js used a pseudo namespace wouldn't that mean
they would have a smaller chance of breaking other JavaScript
like for-in loops?

The for-in loop issues is a consequence of extending the prototypes of
built-in object, and cannot be addressed with the use of simulated
namespaces.
Maybe namespaces could protect unknowing programmers. Not
that it is a great argument but it is somewhat practical.

Protect them form identifying meaningful names for the objects they
create?
I suppose there will be a larger and larger base of libraries
that people can use in their projects. As the available bulk
of libraries increases there is a chance of a namespace between
any two. That is what I was thinking about.

Naming collisions only happen in an execution environment. Any
increasing availability of javascript libraries does not imply
downloading them all to the browser so that they would all be exposed to
the same execution environment. Indeed doing anything of the sort would
be crazy. The situation does not parallel languages like Java, you only
send the code you need to the browser, and that is not going to
indefinitely large or contain unknown code.

Richard.
 
R

RobG

VK said:
(e-mail address removed) wrote: [...]
Does this mean that while evaluating the condition "Serious == null"
that the JavaScript interpreter has looked ahead to see the
declaration? That would be very strange but I find a lot of
JavaScript's activities very strange.

No, it doesn't look ahead, it's even more funny as I see it. On the
parsing stage, when the program text is initially loaded and studied
for tokens, interpreter collects all occurences of
[var][white-space][literal]. These [literal] are being marked as
pre-declared with value undefined. When the script execution starts,
these [literal] are treated as pre-declared with value undefined.

this is why say

<script type="text/javascript">
if (foobar == null) {foobar = {};}

It errors because in neither statement is foobar declared.

I guess that, where foobar has not been declared, statements like:

function blah(){
foobar = 5;
}

create foobar as a global variable to provide a simple way of creating
globals from inside a function. Insistence on the use of 'var' would
require that all globals were declared outside functions, or that the
scope be named in the declaration. This behaviour is also unique to
functions, it does not happen with other objects:

var a = {};
a.b;

creates b as an undefined property of a, there is no need (it's a syntax
error) to write:

var a.b;

or

var a = {var b};


It makes the language more tolerant of programmers who forget to declare
variables - though it might have unexpected consequences. Good
programmers will still write:

var foobar;
function blah(){
foobar = 5;
}

[...]
I guess Brendan Eich knows why did they do this way

Why not ask him? His e-mail address can be found here:

<URL:http://www.mozilla.org/about/staff>


JavaScript was intended to be a simple, forgiving language for web
developers who did not want to learn a full-blown OO language like C++
or Java (at the time Java was touted as the way to make pages
interactive - thank heavens for Mocha/LiveScript/JavaScript).

Its widespread use is a sign that it has succeeded (wildly) - almost to
the total exclusion of other web page scripting or programming
languages. So despite its shortcomings, it can't be all that bad at
what it does.
 
P

petermichaux

Richard said:
Simulated namespaces are a very questionable notion. In other language
the namespaces are resolved when the code is compiled. Javascript must
resolve those long property accessors each and every time they are used.

What are the implications of this statement on the discussion of "Class
Methods" in JavaScript? In particular I am looking at page 126 of
JavaScript: The Definative Guide 4th ed. In the example, he has a class
called "Circle" and wants a class menthod called "max".

function Circle(radius){ stuff }
function Circle_max(a,b){ stuff }
Circle.max = Circle_max;

This example seems like a real mess. Why clutter the global namespace
with Circle_max? Maybe there is some other reason but given that we
probably will only ever call Circle.max we have two better options

Option 1 directly create a class method

function Circle(radius){ stuff }
Circle.max = function(a,b){ stuff };

Option 2 use a function instead of a class method

function Circle(radius){ stuff }
function Circle_max(a,b){ stuff }

In some languages, like Java, Option 1 would allow Circle.max access to
class variables. I think that this is not really an issue in JavaScript
because nothing is private, true? However Option 1 will have slower
execution speed because the interpreter must resolve the '.' every time
we use Circle.max().

So we could/should just use Option 2 which doesn't have much namespace
collision possiblity anyway.

So what the heck was he arguing about when he said on page 126 that
"associating these function with a class gives them a convenient niche
in the JavaScript namespace and prevents namespace collisions." There
is no real benifit and a small perfomance decrease.

Is the objects chapter of this book getting worse the more I read it or
am I out to lunch here?

Thanks,
Peter
 
V

VK

I am looking at page 126 of
JavaScript: The Definative Guide 4th ed. In the example, he has a class
called "Circle" and wants a class menthod called "max".

function Circle(radius){ stuff }
function Circle_max(a,b){ stuff }
Circle.max = Circle_max;

This example seems like a real mess. Why clutter the global namespace
with Circle_max? Maybe there is some other reason but given that we
probably will only ever call Circle.max we have two better options

Option 1 directly create a class method

function Circle(radius){ stuff }
Circle.max = function(a,b){ stuff };

If he was writting his book right now he would most probably use direct
function object augmentation (like above).
It was not thought this way that time yet. All closure/pseudo-protected
members and other things were in the languages nearly since Netscape 3
- but it took 10 years before "discover" them and find for them some
practical use. It's like with math - some formal structures can float
around for centuries before new physics demands fill them with a
practical content.
AFAIK the concept itself of anonymous function expression used in the
right side of assignment is backtracked only to the beginning of this
century - and developed by cabbal members of c.l.j. in their studies of
closures. That is by my (definitely not definitive) archive researches.
How "obvious" it is until one saw it - it still requires an extra
initial abstraction effort.
Option 2 use a function instead of a class method

function Circle(radius){ stuff }
function Circle_max(a,b){ stuff }

That effectively brings us back to the old "Macromedia Notation" used
during the Internet Bubble:
Two capital letter denoting the producer - underscore - constructor
name - underscore - method name:
MM_Circle_getRadius
VK_Foo_setFoobar

That also provide a reasonable reliable namespace protection, but in
the modern OOP terms looks ... lame, no cool :)
In some languages, like Java, Option 1 would allow Circle.max access to
class variables. I think that this is not really an issue in JavaScript
because nothing is private, true?

There are different ways to achieve private status for members in the
conventional script, you may search this group archives.
There is nothing explicetly documented in JavaScript/JScript official
producers' manuals, that's true.
So what the heck was he arguing about when he said on page 126 that
"associating these function with a class gives them a convenient niche
in the JavaScript namespace and prevents namespace collisions."

I presume he did not mean the technical method itself, but the used
naming schema, where all "function-methods" uniformly start with the
main constructor name.
 
V

VK

VK said:
How "obvious" it is until one saw it - it still requires an extra
initial abstraction effort.

.... One more attempt :) :

However "obvious" it is after one saw it still requires an extra
initial abstraction effort.
 
R

Richard Cornford

What are the implications of this statement on the discussion of "Class
Methods" in JavaScript? In particular I am looking at page 126 of
JavaScript: The Definative Guide 4th ed. In the example, he has a
class called "Circle" and wants a class menthod called "max".

function Circle(radius){ stuff }
function Circle_max(a,b){ stuff }
Circle.max = Circle_max;

This example seems like a real mess. Why clutter the global
namespace with Circle_max?

Yes, why do that? One of the reasons that JavaScript the Definitive
Guide is only the least bad javascript book available.
Maybe there is some other reason but given that we
probably will only ever call Circle.max we have two better
options

Option 1 directly create a class method

function Circle(radius){ stuff }
Circle.max = function(a,b){ stuff };

Option 2 use a function instead of a class method

function Circle(radius){ stuff }
function Circle_max(a,b){ stuff }

In some languages, like Java, Option 1 would allow Circle.max
access to class variables. I think that this is not really an issue
in JavaScript

It could be an issue as - Circle.max() - could access other properties
of the constructor through the - this - keyword.
because nothing is private, true?

Well, things put into closures can be restricted in their accessibility
in ways that can resembles notions of 'private'.
However Option 1 will have slower execution speed because the
interpreter must resolve the '.' every time we use Circle.max().

The overhead per dot is not that great so how significant it is depends
a bit on how often you call the static method, and generally static
methods are not used that often. My issue with it is the number of dots
in a simulated namespace and the frequency with witch they would need
to be resolved.
So we could/should just use Option 2 which doesn't have much
namespace collision possiblity anyway.

Not necessarily. The concept of methods that are 'of the class' is well
expressed by making the methods properties of the constructor. If the
functions that are placed in that role really are suited then a small
overhead on the infrequent occasions that they would be referenced
doesn't seem like too great a cost to pay for the ability to associate
genuinely related facilities in a well defined unit.

There are many functions that could be strongly related to a particular
'class', such as virtually any function that acts upon multiple
arguments that must be instances of that 'class' (for example, a
compare function for use when sorting arrays of Circle instances), or
functions that implement concepts closely related to objects of a type
but not necessarily instances of that type (such as a method retiring
the surface area of a circle given its radius).

Where the namespace simulation may have:-

Something.Circle

- the existence of that initial - Something - implies that there may be
more than one 'Circle' in the system, and if they are well named the
implication would be that one or other would be redundant and that one
could be removed and the other used, or an amalgam of the two called
'Circle' would be more appropriate.
So what the heck was he arguing about when he said on page 126 that
"associating these function with a class gives them a convenient niche
in the JavaScript namespace and prevents namespace collisions."

It does prevent namespace collisions. The method in question is called
'max', which happens to also be the name of a static method of the Math
object.
There is no real benifit and a small perfomance decrease.
<snip>

There is a benefit, but the simulated namespace notion takes avoiding
namespace collisions far beyond collecting related functionality.
Exaggerating the performance decrease while addressing an issue that is
not nearly significant enough to justify such an extreme response.

Richard.
 
A

António Marques

Regarding namespaces,

Richard said:
(Regarding name resolution)

The overhead per dot is not that great so how significant it is depends
a bit on how often you call the static method, and generally static
methods are not used that often. My issue with it is the number of dots
in a simulated namespace and the frequency with witch they would need
to be resolved.

I see you haven't pointed out this overhead in your replies to me in the
other thread. Would I be correct in the assumption that having only one
level (one dot) is not problematic?

- the underlying implementation is probably a hashtable or other O(1)
lookup structure

- global names must be resolved, so we have always at least t time for
resolution

- if there is only one dot, then resolution takes 2t

- if the underlying implementation is worse than O(1), then it's best to
divide the lists anyway, and a one dot system may be a good way to do that

From your rationale, I get that you object to Something.Circle.member,
but not necessarily to Circle.member, and think the latter is probably
better than circleMember. Both would be my opinion also, but I'd like to
have some confirmation. I'd certainly prefer to have

20 members in the global namespace with 50 'sub-members' each

than

1000 members of the global namespace

but if I'm missing something, I'd like to be told so.
 
A

António Marques

VK said:
AFAIK the concept itself of anonymous function expression used in the
right side of assignment is backtracked only to the beginning of this
century - and developed by cabbal members of c.l.j. in their studies of
closures.

You have heard of Lisp or Smalltalk? Javascript was modelled after Self,
a protoype-based 'version' of Smalltalk.
Unfortunately, the majority of programmers are oblivious to anything
other than C-like languages, and so javascript has been awfully misused
for years. But it's not like nobody knew better.
 
P

petermichaux

António Marques said:
I'd certainly prefer to have

20 members in the global namespace with 50 'sub-members' each

than

1000 members of the global namespace

Why is this? Are you suggesting that with 1000 members in the global
namespace that the interpreter might have to look through 1000 names to
find the correct function. And with the 20-50 system only look through
a maximum of 70 names?

Peter
 
R

Richard Cornford

António Marques said:
Regarding namespaces,



I see you haven't pointed out this overhead in your replies to me in the
other thread. Would I be correct in the assumption that having only one
level (one dot) is not problematic?

Generally no. There is at least one dot when you reference an instance
member with the - this - keyword.
- the underlying implementation is probably a hashtable or
other O(1) lookup structure

And then there is IE.
- global names must be resolved, so we have always at least t
time for resolution

Scope chain resolution of global variables/functions should be
proportional to the depth of the scope chain when the reference is
made. It will usually be two objects deep in normal functions code.
- if there is only one dot, then resolution takes 2t

I would not put money on that, and certainly not as a general statement
about all implementations.
- if the underlying implementation is worse than O(1), then it's best to
divide the lists anyway, and a one dot system may be a good way
to do that

Only up to a point.
From your rationale, I get that you object to Something.Circle.member,
but not necessarily to Circle.member, and think the latter is probably
better than circleMember.

I also think it is, so long as - member - is a method that really
should belong to Circle.
Both would be my opinion also, but I'd like to
have some confirmation. I'd certainly prefer to have

20 members in the global namespace with 50 'sub-members'
each than

1000 members of the global namespace

but if I'm missing something, I'd like to be told so.

Generally I would too, but I would not worry much about having 200
globals with 5 members each, so long as the globals were the right
objects to have and their members really should belong to them.

Richard.
 
R

Richard Cornford

Why is this? Are you suggesting that with 1000 members in the
global namespace that the interpreter might have to look through
1000 names to find the correct function.
<snip>

Actually it might. But most implementers appear to have been smart
enough to use hash-table like objects to implement javascript's dynamic
objects so in those cases the number of properties on an object doesn't
make much difference to the time or effort involved in finding one.

A better reason for worrying about having so many objects in a single
scope would be the effort involved in managing them. But it is not a
realistic scenario as 1000 objects/functions/properties is a great deal
of javascript so unless everything in the entire system was global that
would imply a script far too large to even consider sending to a
browser.

Large systems are better created in an OO style, and then the vast bulk
of the javascript code will be in (hopefully anonymous) functions
assigned as properties of the constructor functions' prototypes
(becoming methods of the object instances). If you are doing that and
still had 1000 global properties the whole system would be enormous.

It is the fact that even a big system in an OO style will not have an
unmanageable number of global properties if it is going to be viable to
be sending it all to a web browser, that encourages me to think that
namespace simulation is unnecessary.

Richard.
 
P

petermichaux

Richard said:
I also think it is, so long as - member - is a method that really
should belong to Circle.

Better by what criteria?

Generally I would too,

What makes it better?

I'm starting to think your reasons are programmer preference. That is
fine if it makes the code more maintainable for you. However if there
is a perfomance bottleneck then I would have no problem writing
Circle_member rather than Circle.member. I don't use underscore much in
JavaScript anyway so they both look the same to me.

Peter
 
P

petermichaux

Richard said:
<snip>

Actually it might. But most implementers appear to have been smart
enough to use hash-table like objects to implement javascript's dynamic
objects so in those cases the number of properties on an object doesn't
make much difference to the time or effort involved in finding one.

I just tested this in FireFox. In the tests below it looks like the
1000 members way took between 650-800 ms. The 20-50 method took between
700-850 ms.

<html>
<head>

<script type='text/javascript'>
var i;
var j;

for(i=0;i<50;i++){
eval("var Serious"+i+"={};");
for(j=0;j<20;j++){
eval("Serious"+i+".foo"+j+"=function(){};");
}
}

var start = new Date();
for (i=0;i<100000;i++){
Serious24.foo9();
}
var end = new Date();

alert(end-start);
</script>

</head>
<body>

</body>
</html>



<html>
<head>

<script type='text/javascript'>
var i;

for(i=0;i<1000;i++){
eval("function Serious_foo"+i+"(){};");
}

var start = new Date();
for (i=0;i<100000;i++){
Serious_foo499();
}
var end = new Date();

alert(end-start);
</script>

</head>
<body>

</body>
</html>
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top