Js variable assignment

encountered a problem when writing js. The return value obtained by $post is set to data.menu , which is an array
with variables a and b ,

.
var i
for (i = 0; i < data.menu.length; iPP) {
  this.a[i] = data.menu[i]
}
this.b = data.menu

(this is what I wrote in the .vue file. a and b are both empty arrays defined in data , so use this. )
results the results are different and different in use, only b can be used normally (as a variable in component)
when comparing, if you use if (a [0] .data1 = b if (a [0] = b [0]) and other ways to compare array elements or internal values, the result is true ,
but a direct comparison if (a = b) is false , I don"t know why

Mar.12,2021

it is obvious that the javascript array cannot directly compare whether it is equal or not.


object is a reference type, objects that are not the same reference are not equal


an and b are reference types, their reference addresses are compared when =, and a loop assignment is a deep copy, so when false


js can not directly use = = or = to determine whether two arrays are equal, whether equal or congruent, false, will be returned. To determine whether two arrays in JS are the same, you need to convert the array to a string before making a comparison.


your an is cycled, indicating that an is always equal to the last set of data. And b is the whole set of data. Your previous comparison will be equal, which only means that the two values you judge are equal.
if (a [0] .data1 = b [0] .data1), if (a [0] = b [0]) the comparison here is all specific values
if (a = b) here is the comparison of the whole data, and an is only the last iLead b is all the data


[] = [] learn


when a [I] = menu [I], a [I] pointer points to menu [ However, a still points to the array at initialization, not menu, but after b assignment, the pointer points directly to the array corresponding to menu

.
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-1b3b41e-2c264.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-1b3b41e-2c264.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?