What does this code mean?

   const categories = [];
        for (let i = 0; i < this.keyword.datas.length; iPP) {
          if (i === 0) {
            categories.push({
              name: this.keyword.datas[0].type,
            });
          }
          for (let j = 0; categories[0] !== undefined && j < categories.length; jPP) {
            if (categories[j].name === this.keyword.datas[i].type) {
              // 
              break;
            }
            if (j === categories.length - 1) {
              categories.push({
                name: this.keyword.datas[i].type,
              });
            }
          }
        }

what does this code mean? Those who understand can help explain it. Now I am going to rewrite it, but I can only understand half of it

.
Oct.15,2021

categories should be category or directory
there is a I that seems to have an outer loop

.

if there is no name = this.keyword.datas[ I] .type item in the categories array,
put this.keyword.datas[ I] .type in categories

.
if (j = categories.length-1) {
categories.push ({
name: this.keyword.datas[ I] .type,
});
}

this judgment is to cycle to the end. If you haven't found it, put this.keyword.datas[ I] .type in categories

.

the first newly created array will only push to one value, which is not useful to compare with another to find the last if of the direct break, is it? Because you will only walk push once, then the length is always 1


create an array categories
extract the type values of the objects in the keyword.datas array to generate {name: type} json object
in the process of inserting the type object at the end of the categories to remove the duplicate type

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