By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,605 Members | 2,128 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,605 IT Pros & Developers. It's quick & easy.

f ?

P: n/a
<html><head><title>f ?</title><script>
window.onload= function () {
var a= 0;

function f () { alert("cero") };

if (a === 1) {
function f () { alert("uno") };
} else if (a === 2) {
function f () { alert("dos") };
} else if (a === 3) {
var f= function () { alert("tres") };
}

f();
};
</script></head><body></body></html>

(FF2, FF3) -cero.
(Safari, Opera, IE) -dos.

--Jorge.
Jul 20 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
<html><head><title>What is f ?</title><script>
window.onload= function () {
(function (f) {

if (false) {
function f () { alert("uno") };
}
f();

})(function () { alert("dos") });
};
</script></head><body></body></html>

(FF2, FF3) -dos.
(Safari, Opera, IE) -uno.

--Jorge.
Jul 20 '08 #2

P: n/a
On Jul 20, 6:32*pm, "Richard Cornford" <Rich...@litotes.demon.co.uk>
wrote:
>
If you want to ask a question putting that question in the form of words
will make the situation a lot clearer (a real subject lien that states
the subject of your posts is also a good idea).
Still, you got it perfectly. Now it's clear as an unmodied lake.

Hopefully there won't be many more gaps in forthcoming ECMAScript
specification(s).

Thank you,
--Jorge.
Jul 20 '08 #3

P: n/a
Jorge wrote:
>On Jul 20, 6:32 pm, Richard Cornford wrote:
>If you want to ask a question putting that question in the form
of words will make the situation a lot clearer (a real subject
lien that states the subject of your posts is also a good idea).
Still, you got it perfectly. Now it's clear as an unmodied lake.
But do you expect to be given the same leeway after you have been
warned?
Hopefully there won't be many more gaps in forthcoming ECMAScript
specification(s).
There will be thousand of similar possible syntax constructs that have
no specified meaning in the new specifications, and there will be
explicit provision for syntax extensions. Brendan Eich sees extensions
as a good thing and nobody has argued a strong counter-case yet. And the
fact that we have been coping with syntax extensions for the past decade
or more suggest that they are not such a bad thing. Many developments in
the language (such as function expressions) appear to have started out
as syntax extensions that were later formalised.

And the specific issue of 'out of context' function declarations is to
be left precisely as it is now in the ES3.1 spec (except for its
'strict/cautious' mode where it is proposed that multiple declarations
of like-named functions within a single scope will generate an error
when compiled (although it is possible that such a restriction will not
be applied if those declarations appear in a location where the spec
does not allow them (the spec cannot specify the handling of unspecified
constructs))). There is no desire to formalise either of the existing
syntax extensions, and that would declare the other existing possibility
as being formally 'incorrect'.

Richard.

Jul 20 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.