[英]Make the hash value unique in javascript?
For example I am having the hash 例如我正在哈希
var sample={};
sample["test"] = [];
sample["test"].push({name: "test"});
sample["test"].push({name: "test"});
The sample hash should only contain unique values. 样本哈希应仅包含唯一值。
Yes i got the solution for that 是的,我为此找到了解决方案
var sample = [{ id : 1, name : 'Name' }, { id : 1, name : 'Name' }];
var obj = { id : 1, name : 'Name' };
var sample = [obj, obj];
uniq(sample)
Hej man it isn't possible to got another hash value from 2 same value's. 嘿,不可能从2个相同的值中获得另一个哈希值。 For simplify a hash operation is likely like plus so you got 1 + 2 = 3. It is not that easy but I hope you got he point.
为简化起见,哈希运算很可能像加号,所以您得到1 + 2 =3。这并不是那么容易,但我希望您能理解他的观点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.