Array.prototype.shared >= 0.1.0
Purpose
Get the shared value between the 2 arrays
Syntax
Array#shared
(
Arrayarr
Functioncast_function
);
Parameters
arr
- The array to test against
cast_function
- Function to use to cast values to compare them
Return values
Array
New array
Examples
Return the shared values
var a = [0,1,2,47,99,100],
b = [2,47,55,96,200];
a.shared(b);>>> [2, 47]
Cast values for comparing
var a = ['1', '2', '3', '4'],
b = ['1.1', '2.0', '3.3', '4.0'];
a.shared(b, Number);>>> ["2", "4"]
Comments