[whatwg] link.sizes and [PutForwards=value]
Tab Atkins Jr.
jackalmage at gmail.com
Mon Aug 1 11:29:04 PDT 2011
On Sat, Jul 30, 2011 at 12:51 AM, Cameron McCormack <cam at mcc.id.au> wrote:
> There is a disadvantage. In JS, doing a comparison between two objects,
> regardless of whether they have custom stringification behaviour, will
> compare based on object identity and not the string.
>
> <!DOCTYPE html>
> <iframe id=x src=b.html></iframe>
> <iframe id=y src=b.html></iframe>
> <script>
> window.onload = function() {
> var xw = document.getElementById("x").contentWindow;
> var yw = document.getElementById("y").contentWindow;
> alert([xw.location, yw.location,
> xw.location == yw.location].join("\n"));
> };
> </script>
>
> The two Location objects stringify to the same thing, but are not ==. I
> think this can be confusing.
It's a confusion shared by all objects, though:
var x = [1,2];
var y = [1,2];
alert([x,y,x==y).join(' ');
This alerts "1,2 1,2 false".
Unfortunately, object equality is of fairly limited usefulness in JS.
~TJ
More information about the whatwg
mailing list