其他分享
首页 > 其他分享> > ES6 利用扩展运算符将伪数组转成真的数组

ES6 利用扩展运算符将伪数组转成真的数组

作者:互联网

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>扩展运算符应用</title>
</head>
<body>
    <div>1</div>
    <div>2</div>
    <div>3</div>
    <div>4</div>
</body>
<script>
    /*利用扩展运算符将伪数组转成真数组*/
    var oDivs= document.getElementsByTagName('div');
    console.log(oDivs)
    console.log( oDivs instanceof Array)  //判断是不是真数组

    let arr =[...oDivs];
    console.log(arr)
    console.log(arr instanceof Array)

</script>
</html>

  

标签:ES6,arr,console,数组,运算符,oDivs,log
来源: https://www.cnblogs.com/malong1992/p/12774186.html