Skip to content

Instantly share code, notes, and snippets.

@mactive
Last active December 21, 2015 18:49
Show Gist options
  • Save mactive/6350388 to your computer and use it in GitHub Desktop.
Save mactive/6350388 to your computer and use it in GitHub Desktop.
js array minus
// console.log(itemUsedCurrencys);
// console.log(itemOriginCurrencys);
var itemOriginCurrencys = ['USD', 'HKD', 'CNY', 'EUD'];
var itemUsedCurrencys = ['USD', 'HKD'];
var i = itemOriginCurrencys.length;
while (i--) {
var index = itemUsedCurrencys.indexOf( itemOriginCurrencys[i] )
// console.log('check : '+itemOriginCurrencys[i] + " pos: "+ index);
if (index >= 0) {
itemOriginCurrencys.splice(i, 1);
}
}
// itemOriginCurrencys = ['CNY', 'EUD'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment