[英]Why does Blob constructor only take an array as the first argument?
Just trying to wrap my head around Blob只是想把我的头绕在 Blob 上
Reading this: https://developer.mozilla.org/en-US/docs/Web/API/Blob gives no explanation as to why the first argument must be an array.阅读: https : //developer.mozilla.org/en-US/docs/Web/API/Blob没有解释为什么第一个参数必须是数组。
If I do supply multiple things in that array, it just stitches them together end to end which seems like a really odd feature to force on every blob creation如果我确实在该数组中提供了多个内容,它只会将它们首尾相连地缝合在一起,这似乎是一个非常奇怪的功能,可以强制创建每个 blob
New Blob(["a", "b"])
is the exact same as
New Blob(["a" + "b"])
why??为什么??
Not every input can be concatenated by +
sign.并非每个输入都可以用
+
号连接。 For example you may want to concatenate 2 blobs:例如,您可能想要连接 2 个 blob:
const blob = new Blob([new Blob(['a']), new Blob(['b'])])
// ab
It's not the same as:它不同于:
const blob = new Blob([new Blob(['a']) + new Blob(['b'])])
// [object Blob][object Blob]
Using an array as an input it's a bit more flexible as Blob implementation will take care of concatenation of the given input.使用数组作为输入更加灵活,因为 Blob 实现将处理给定输入的串联。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.