SOURCE

function createStore() {

    let currentState = {
        value: 1
    }

    const getState = () => currentState;

    const modifyState = (payload) => {
        currentState = {
            ...currentState,
            ...payload
        }
    }

    return {
        getState,
        modifyState
    }
}

const store1 = createStore().getState()
const store2 = createStore().getState()
console.log(store1 === store2) //false


// 函数柯里化
function func1(name) {
    this.name = name
    getName: function a() {
        return this.name;
    }
}

// bind new prototype

// 校验
function check(str, reg) {
    return reg.test(reg);
}

// https://github.com/ziishaned/learn-regexs
const v1 = check('abc.e.f', /(\w)*(.)/)
console.log(v1)
const v2 = check('123.e.f', /(\d)*(.)/)
console.log(v2)

console.log("------分割线-----")

let first=null;
let last=null;

// 链表
const createObj = (value) => {
    let tmp = (last = { value, prev: last, next: null })
    if (tmp.prev) {
        tmp.prev.next = tmp;
    } else {
        first = tmp
    }
    return tmp
}

let obj1 = createObj(1)
console.log(obj1)
let obj2 = createObj(2)
console.log(obj2)
// let obj3 = createObj(3)
// console.log(obj3)
console 命令行工具 X clear

                    
>
console