Check for an instance of ArrayBufferView?

前端 未结 2 2110
被撕碎了的回忆
被撕碎了的回忆 2021-02-15 09:24

Background

With a bit of research I\'ve found that, although ArrayBufferView wasn\'t initially exposed (through [NoInterfaceObject]) there appeared to be

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-15 10:12

    Better answer I guess:

    var arr = new Float64Array(100);
    
    arr instanceof (new Uint16Array()).constructor.prototype.__proto__.constructor //true
    

    works in Chrome & Firefox, maybe other browsers too

提交回复
热议问题