Skip to content

Instantly share code, notes, and snippets.

@lichenbuliren
Created October 27, 2016 08:49
Show Gist options
  • Save lichenbuliren/34eae8847904d567619b21bd503e27be to your computer and use it in GitHub Desktop.
Save lichenbuliren/34eae8847904d567619b21bd503e27be to your computer and use it in GitHub Desktop.
function sku() {
var result = [];
var arr = Array.prototype.slice.call(arguments);
(function fn(parameter, array, len) {
if (len == 0) return result.push(parameter);
for (var i = 0; i < array[len - 1].length; i++) {
fn(parameter.concat(array[len - 1][i]), array, len - 1);
}
})([], arr, arr.length);
return result;
}
sku(['16GB','32GB','64GB'],['金色','银色','黑色'],['移动','联通']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment