标签:键值 set null 对象 [] trie user log push
let s = new Set();
s
.add("x")
.add("y");
console.log(s);
var a =[];
a.push(1,2,3,4,5,4,3,2,1);
var user = new Set(a);
console.log(user);
数组转set
var arr = [1,2,3,4,1,2,3,4];
var s = new Set([...arr]);
console.log(s);
var user = new Set([1,2,3,4,5]);//创建一个构造函数;
var user = new Set();//创建一个set对象;
user
.add(1)
.add(null)
.add("1")
.add({});
delete (1);
let set = new Set([1,2,3,"a"]);//创造一个构造函数
for (let i of set.keys()){//循环set中的键名
console.log(i)
}
let a = new Set([1,2,1,1,3]);
for (let i of a.values()){//遍历set中的值
console.log(i)
}
let a = new Set([2,4,3,1]);
for (let i of a.entries()){//循环set中的键值对
console.log(i)
}
let user = new Set(["a","b","c","d"]);//传进去的要是个数组
user.forEach(function(a,b){//遍历出他的值和键;
console.log(a);
});
var week = new Set(["a"]);//传进去的要是个数组
week.forEach(function(a,b,c){//遍历set中的键、值、本身;
console.log(a,b,c);
});
let map = new Set([//创建一个集合
["a","b"],
["c","d"]
]);
for (let k of map.values()){//循环map中的值名
console.log(k)
}
遍历出set中的值
var set = new Set([‘a‘,‘a‘],[‘b‘,‘a‘],[‘c‘,‘a‘]);//传进去的要是个数组
set.forEach(function(a){//遍历set中的键、值、及本身
console.log(a);
});
遍历出set中的之间的键值对
let myMap = new Map().set(true, 7).set({foo: 3}, [‘abc‘]);//创建一个Map
console.log(myMap);//输出键值对
标签:键值 set null 对象 [] trie user log push
原文地址:http://www.cnblogs.com/t258/p/6754230.html