Samman Thapa Samman Thapa - 1 year ago 61
Node.js Question

Should.js: check if two arrays contain same strings

I have two arrays:

var a = ['a', 'as', 'sa'];
var b = ['sa', 'a', 'as'];

Is there anything special in shouldJS to test if these two arrays have same items? Anything Like


that can test them? Here, xyz is what I am looking for.

Answer Source

A naive, but possibly sufficient solution would be to sort the arrays before comparing them:


Note that sort() works in-place, mutating the original arrays.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download