<script>
window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder;
Blob.prototype.slice = Blob.prototype.slice || function(start, length) {
return this.webkitSlice(start, start + length);
}
</script>
These codes are from a background page of a Chrome extension. Any idea or hint will be highly appreciated.
this says set
window.BlobBuilderto what it is already set to if whatever it is set to is truthy; if whatever it’s set to currently is falsey, then set it towindow.WebKitBlobBuilder. This is a general approach used to assign a value to a variable if it doesn’t already have a truthy value. Truthy values are anything that are not falsey values, and the falsey values arenullundefinedfalse''0NaNThe next line uses similar syntax
This sets the
slicefunction on theBlobprototype object either to itself if the current value is truthy, or to a function that will use thewebkitSlicefunction defined onthis(which I assume will beWebKitBlobBuilderin this instance).