ES6 Set & Map
Map & Set
https://github.com/xgqfrms/RAIO/issues/167
ES6 Map
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
const arr = [
"INNERCODE", "SECUCODE", "SECUABBR", "TRADINGDAY", "LASTWEEKTRADINGDAY", "CLOSEPRICE", "CHANGE", "CHANGERANGE",
"INNERCODE", "SECUCODE", "SECUABBR", "TRADINGDAY", "LASTWEEKTRADINGDAY", "CLOSEPRICE", "CHANGE", "CHANGERANGE",
];
let map_arr = new Map(arr);
// Uncaught TypeError: Iterator value INNERCODE is not an entry object at new Map (<anonymous>)
let set_arr = new Set(arr);
// Set(8) {"INNERCODE", "SECUCODE", "SECUABBR", "TRADINGDAY", "LASTWEEKTRADINGDAY", …}
let new_arr = [...set_arr];
// (8) ["INNERCODE", "SECUCODE", "SECUABBR", "TRADINGDAY", "LASTWEEKTRADINGDAY", "CLOSEPRICE", "CHANGE", "CHANGERANGE"]
ES6 Set
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
let mySet = new Set();
mySet.add(1);
// Set [ 1 ]
mySet.add(5);
// Set [ 1, 5 ]
mySet.add(5);
// Set [ 1, 5 ]
mySet.add('some text');
// Set [ 1, 5, 'some text' ]
setter
setter - JavaScript | MDN
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/set
Set
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
const set1 = new Set([1, 2, 3, 4, 5]);
console.log(set1.has(1));
// expected output: true
console.log(set1.has(7));
// expected output: false
console.log(set1.add(7));
// expected output: true
console.log(set1.has(7));
// expected output: true
console.log(set1.has(6));
// expected output: false
refs
©xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!