The judgment of two anonymous functions is not equal.

problem description


I have written two function with the same method body in two different vue components, and they all have the same scope except that they define different scopes, so how can I tell that they are different? Or whether they can get their scope

the environmental background of the problems and what methods you have tried

I tried to encode the method with MD5 to get the id in the figure, but this id is the same.


compare function references directly

var a=function(){}
var b=function(){}
console.log(a===b)

provides an idea: convert a function to a string and then compare it. The
function test (args) {console.log (args)};
function test.toString (); is "function test (args) {console.log (args)}".
compares the values that two functions convert to strings, and if they are equal, the two functions are the same.


do you mean to judge that the scope of these two identical functions is different?
many methods because js is lexical scope, in fact, their scope is the declared location
method 1:
two vue files have a global variable but a different value
and then directly return the global variable in the function method. See if it is the same
method 2:
return this directly in the function

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b36407-343ab.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b36407-343ab.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?