The == operator on v8::Local compares if two Locals are referring to the
same JavaScript object (which can, of course, be a function) by object
identity (aka reference). (Structural equality is the opposite!)
Note that two functions can contain the same code, but have different
object identity:
function GetFun() {
return function() { /* do something funny */ }
}
var f1 = GetFun();
var f2 = GetFun();
f1 === f2; // false!
f1.property = "yay";
f2.property === undefined; // true!
If you had v8::Locals for f1 and f2, then local1 == local2 would be false.
On Tue, Mar 21, 2017 at 7:15 PM, Hanyun Tao <[email protected]> wrote:
> Hi all,
>
> I'm new to v8 and I want to know more about the equality check (==)
> between two v8::Local<v8::Object>.
>
> Currently I'm using instrumenting chromium browser. In chromium,
> registered event listeners are stored inside a map like data structure, and
> I can use the getListenerObject() method to get the v8::Local<v8::Object>
> correspond to each event listener, which could be a function reference, or
> reference to an object with handleEvent property.
>
> My goal is to tell if two different event listener will invoke the same
> javascript or not. Someone told me that I can do this by comparing two
> v8::Local<v8::Object> by value. I followed the suggestion and implements a
> function that returns unique integer ID for unique v8::Local<v8::Object>
> value. However when I test it on real webpage, I found that almost every
> event listeners are mapped to the same ID.
>
> I'm not confident with this result so I want to ask a question here. What
> does the equality check (==) between two v8::Local<v8::Object> check? Does
> it implies that the two object are structurally equal (contains the same
> function/object reference), or it means something else?
>
> Best regards,
>
>
> --
> --
> v8-users mailing list
> [email protected]
> http://groups.google.com/group/v8-users
> ---
> You received this message because you are subscribed to the Google Groups
> "v8-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.