The way JS collections store values

this.add = function(value) {
  if(!this.has(value)){
    items[value]=value;
    return true;
  }
  return false;
}
for this line of code: items [value] = value , the book says: when you add a value, save it as both a key and a value, which helps to find the value .
< H2 > question: how does it help to find this value in this way? Is it advantageous to use the value to find the value? What"s wrong with passing a button? < / H2 >
Mar.01,2021

look at the application scenario. Sometimes value itself is suitable as a key, which is easy to find. In other cases, it is not easy to find an attribute in value that can be used as a key, so you might as well use it as a key.


how to pass the key add (value) is not add (key,value) say that the front leg of this sentence is the add method that simulates set

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