admin管理员组

文章数量:1287624

Actually, I'm doing a script which removes row duplicates from an array. And it works properly, but I don't know why :) Here is a string of my code:

if (refValues[i].join() == uniqueAddrs[n].join())

Actually, I'm doing a script which removes row duplicates from an array. And it works properly, but I don't know why :) Here is a string of my code:

if (refValues[i].join() == uniqueAddrs[n].join())
Share Improve this question edited Feb 13, 2015 at 14:17 Cameron Roberts 7,3771 gold badge22 silver badges34 bronze badges asked Feb 13, 2015 at 8:44 Oleg DatsenkoOleg Datsenko 791 gold badge1 silver badge8 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

It's worth mentioning that .join() is actually a core Javascript method, not a Google Apps Specific one.

You can see the documentation here: https://developer.mozilla/en/docs/Web/JavaScript/Reference/Global_Objects/Array/join

refValues and uniqueAddrs are array variables, and join() method just concatenates all elements in these arrays to a string. This is a quick and dirty way to check string arrays for equality.

本文标签: javascriptWhat join() method does in Google App ScriptStack Overflow