前端学习笔记202310学习笔记第一百壹拾一天-作用域&作用域链&预编译&闭包基础17

function breadMsg(num) {
    var breadNum = arguments[0] || 10
    function supply() {
        breadNum += 10
        console.log(breadNum)
    }
    function sale() {
        breadNum -= 10
        console.log(breadNum)
    }
    return [supply, sale]
}
var breadMsg = breadMsg(50)
breadMsg[0](10)
breadMsg[0](11)

运行结果

posted @ 2023-11-08 16:39  前端导师歌谣  阅读(2)  评论(0编辑  收藏  举报  来源