这里给大家分享我在网上总结出来的一些知识,希望对大家有所帮助背景昨天在看一道笔试题的时候本以为很简单,但是结果不是我想象的那样,直接上笔试题。constarray=newArray(5).map((item)=>{returnitem={name:'1'}});console.log(array);//请写出输出结果我想象的答案:[{name:'1'},{name:'1'},{name:'1'},{name:'1'},{name:'1'}];实际的答案:[empty×5]为什么会这样了?猜想1我第一个想到的是newArray(5)生成的数组是[undefined,undefined,undef
这里给大家分享我在网上总结出来的一些知识,希望对大家有所帮助背景昨天在看一道笔试题的时候本以为很简单,但是结果不是我想象的那样,直接上笔试题。constarray=newArray(5).map((item)=>{returnitem={name:'1'}});console.log(array);//请写出输出结果我想象的答案:[{name:'1'},{name:'1'},{name:'1'},{name:'1'},{name:'1'}];实际的答案:[empty×5]为什么会这样了?猜想1我第一个想到的是newArray(5)生成的数组是[undefined,undefined,undef
下面代码输出什么constMainApp=()=>{constparentRef=useRef();constchildRef=useRef();constparentClickFun=useCallback(()=>{console.log('reactparent');},[]);constchildClickFun=useCallback(()=>{console.log('reactchild');},[]);useEffect(()=>{document.addEventListener('click',()=>{console.log('document');});parentRe
下面代码输出什么constMainApp=()=>{constparentRef=useRef();constchildRef=useRef();constparentClickFun=useCallback(()=>{console.log('reactparent');},[]);constchildClickFun=useCallback(()=>{console.log('reactchild');},[]);useEffect(()=>{document.addEventListener('click',()=>{console.log('document');});parentRe