From: Thomas 'PointedEars' Lahn on
David Mark wrote:

> Thomas 'PointedEars' Lahn wrote:
>> David Mark wrote:
>> > Thomas 'PointedEars' Lahn wrote:
>> >> David Mark wrote:
>> >> > Thomas 'PointedEars' Lahn wrote:
>> >> >> David Mark wrote:
>> >> >> > RobG wrote:
>> >> >> >> Garrett Smith wrote:
>> >> >> >> > Replace: "</" + "script>"
>> >> >> >> > with: "<\/script>";
>> >> >> >> > Replace: "</td>";
>> >> >> >> > with: "<\/td>";
>> >> >> >>
>> >> >> >> I don't understand the issue here, is it specifically
>> ^^^^^^^^^^^^^^^^^^
>> >> >> >> with the TD end tag? Or is it more generally with end tags
>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> >> >> >> in HTML sent as an XHR response?
>> ^^^^^^^
>> >> >> > No, it refers to markup in script (e.g. document.write calls).
>> >> >> [...]
>> >> >> > Nothing to do with the tag type.
>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> >> >> [...]
>> >> > The type of tag serialized in the string (e.g. TD vs. SCRIPT).
>> ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^
>> >> > Are you proposing to refer to these as *elements*?
>> >> TD is one *element* type, SCRIPT is another.
>> >>
>> >> <http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.1>
>> > Are you kidding?
>> No. Have you read that part of the Specification carefully?
>
> No need.

Apparently there is.

>> >> > I think not as we are talking about just one (ending) tag (not
>> >> > both).
>> >> Iff you had meant "tag type" to distinguish between start tags and
>> >> *end* tags, which AIUI you have not, then that would have been
>> >> acceptable.
>> > As you understand what?
>> You were referring to TD and SCRIPT as different "type(s) of tag".
>
> You misunderstand. They are different "types of tags" (as only the
> ending tags of each are present in the serialization). If I had meant
> element, I should have said element. :)

If so, it was easy to misunderstand, as in "potentially unclear".

> They are different "types of tags" (as only the
> ending tags of each are present in the serialization). If I had meant
> element, I should have said element. :)

So you meant "e.g. </td> vs. </script>" (not "e.g. TD vs. SCRIPT"), and
called the former "type(s) of tags" or "tag type", which is potentially
unclear after all?

For if anything could be called "type of tag" or "tag type", it is the
difference between start tag and end tag, and in that sense both `</td>'
and `</script>' are of the same type. But those who did not know the
correct terminology could, mislead by your statement, assume that what you
call "type of tag" or "tag type" would refer to what is correctly called
the element type.

You garbled the quotations; please learn to quote. (Not using Google
Groups for posting would help a lot there.)


PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
From: Asen Bozhilov on
Garrett Smith wrote:
> Asen Bozhilov wrote:
>
> Move that paren inwards, to group the FunctionExpression, as:
> (function(){})();

What is the difference between:

typeof function(){}();

(function(){}());

(function(){})();

Please explain.


> > Expected value of `x` is `null`, but if VO is implement as a native
> > object value of `x` will be 10. Because:
>
> [...]
>
> If - VO - is a variable object, then it must have no [[Prototype]].

But documentation permit VO to have [[Prototype]] from:

| 10.1.4 Scope Chain and Identifier Resolution
| 2. Call the [[HasProperty]] method of Result(1), passing the
Identifier as the property.

I don't think that is a bug in Blackberry9000, because documentation
permit that behavior. That is implementation-dependent too.

Btw 1: In FAQ link above "BlackBerry JavaScript Reference"
<URL: http://docs.blackberry.com/en/developers/deliverables/8861/>
Links in that page ares broken. They redirect me to:
<URL: http://docs.blackberry.com/404error.jsp>

Proper URL is:
<URL: http://docs.blackberry.com/en/developers/deliverables/11849/>

Btw 2: Why not include in "Code Guidelines" `delete` operator over a
host objects, because host object can implement own internal
[[Delete]] method and using `delete` operator for host objects can be
error-prone.

Regards.
From: Lasse Reichstein Nielsen on
Asen Bozhilov <asen.bozhilov(a)gmail.com> writes:

> Garrett Smith wrote:
>> Asen Bozhilov wrote:
>>
>> Move that paren inwards, to group the FunctionExpression, as:
>> (function(){})();
>
> What is the difference between:
>
> typeof function(){}();
>
> (function(){}());
>
> (function(){})();
>
> Please explain.

The last two are equivalent. The first evaluates to a string instead
of the undefined value :)

I would recommend (function(){})() over (function(){}()) for two reasons:
readability (it's easier to see the grouping) and convention (it's easier
to recognize what's going on). There is no technical reason to prefer one
over the other.

/L
--
Lasse Reichstein Holst Nielsen
'Javascript frameworks is a disruptive technology'

From: Dmitry A. Soshnikov on
On Dec 28, 5:20 pm, Lasse Reichstein Nielsen <lrn.unr...(a)gmail.com>
wrote:
> Asen Bozhilov <asen.bozhi...(a)gmail.com> writes:
> > Garrett Smith wrote:
> >> Asen Bozhilov wrote:
>
> >> Move that paren inwards, to group the FunctionExpression, as:
> >> (function(){})();
>
> > What is the difference between:
>
> > typeof function(){}();
>
> > (function(){}());
>
> > (function(){})();
>
> > Please explain.
>
> The last two are equivalent. The first evaluates to a string instead
> of the undefined value :)
>
> I would recommend (function(){})() over (function(){}()) for two reasons:
> readability (it's easier to see the grouping) and convention (it's easier
> to recognize what's going on). There is no technical reason to prefer one
> over the other.
>

Meanwhile, there's a test case, when that two forms will not be
equivalent. It's related to automatic semicolon insertion when
semicolon is not inserted in case of one function expression form:

var foo = function () {
alert(arguments[0]);
}

(function () {return 'x';}())

In this case we've "forgot" semicolon after FE referenced by `foo'
variable, try to run it, you'll see the result.

var foo = function () {
alert(arguments[0]);
}

(function () {return 'x';})()

Meanwhile, this form (where we've also "forgot" semicolon after `foo')
will throw an exception.

Sure, this case should be changed to the following with semicolons:

var foo = function () {
alert(arguments[0]);
};

(function () {return 'x';})();

In this form the grouping operator of the second one FE is not treated
as brackets of the call expression, as it was in two previous cases.

/ds
From: Garrett Smith on
Lasse Reichstein Nielsen wrote:
> Asen Bozhilov <asen.bozhilov(a)gmail.com> writes:
>
>> Garrett Smith wrote:
>>> Asen Bozhilov wrote:
>>>
>>> Move that paren inwards, to group the FunctionExpression, as:
>>> (function(){})();
>> What is the difference between:
>>
>> typeof function(){}();
>>
>> (function(){}());
>>
>> (function(){})();
>>
>> Please explain.
>
> The last two are equivalent. The first evaluates to a string instead
> of the undefined value :)
>
> I would recommend (function(){})() over (function(){}()) for two reasons:
> readability (it's easier to see the grouping) and convention (it's easier
> to recognize what's going on). There is no technical reason to prefer one
> over the other.
>
Right. All three are valid ExpressionStatement.

I had (mis?)believed a parse error in a browser, and so have always that
approach. I can't create an error by wrapping the entire thing in
parens. Safari 2 is happy with:-

javascript: (function(){alert(1)}());

But it is also important to remember that an ExpressionStatement can't
begin with `function` keyword because that would be ambiguous with a
FunctionDeclaration. Nor can an expression statement begin with `{`, as
that would be ambiguous with a Block, and so:-

(function(){}());

- is valid, but:-

function(){}(); // SyntaxError.

- is not.
--
Garrett
comp.lang.javascript FAQ: http://jibbering.com/faq/