symbol
// 创建 symbol
let s = Symbol();
// console.log(s,typeof s); // Symbol() "symbol"
let s2 = Symbol('Eric');
let s3 = Symbol('Eric');
// console.log(s2); // Symbol(Eric)
// console.log(s2 === s3); // false
// Symbol.for 创建
let s4 = Symbol.for('Eric');
let s5 = Symbol.for('Eric');
// console.log(s4,typeof s4); // Symbol(Eric) "symbol"
// console.log(s4 === s5); // true
// 不能与其他数据 进行运算
// js 数据类型
// USONB you are so niubility
// u undefined
// s string symbol
// o object
// n null number
// b boolean
// 向对象 添加 方法 up down
let game = {
}
// 声明一个对象
// let methods = {
// up: Symbol(),
// down:Symbol()
// };
// game[methods.up] = function(){
// console.log('我可以改变形状');
// }
// game[methods.down] = function(){
// console.log('我可以快速下降');
// }
// console.log(game);
// let youxi = {
// name:"狼人杀",
// [Symbol('say')]:function(){
// console.log('我可以发言');
// },
// [Symbol('zibao')]:function(){
// console.log('我可以自爆');
// }
// }
// console.log(youxi);
// 内置值
// class Person {
// static [Symbol.hasInstance](param){
// console.log(param);
// console.log('我被用来检测类型了');
// }
// }
// let o = {};
// console.log(o instanceof Person);
const arr = [1,2,3];
const arr2 = [4,5,6];
// console.log(arr.concat(arr2)); // (6) [1, 2, 3, 4, 5, 6]
arr2[Symbol.isConcatSpreadable] = false;
// console.log(arr.concat(arr2)); // (4) [1, 2, 3, Array(3)]
我是Eric,手机号是13522679763

浙公网安备 33010602011771号