Fixed javascript helper for typed arrays of scalars not taking into (#4068)

account underlying buffer's byte offset.
diff --git a/src/idl_gen_js.cpp b/src/idl_gen_js.cpp
index fec5780..23fd52c 100644
--- a/src/idl_gen_js.cpp
+++ b/src/idl_gen_js.cpp
@@ -581,7 +581,7 @@
         code += object_name + ".prototype." + MakeCamel(field.name, false);
         code += "Array = function() {\n" + offset_prefix;
         code += "new " + GenType(vectorType) + "Array(this.bb.bytes().buffer, "
-          "this.bb.__vector(this.bb_pos + offset), "
+          "this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), "
           "this.bb.__vector_len(this.bb_pos + offset)) : null;\n};\n\n";
       }
     }
diff --git a/tests/monster_test.bfbs b/tests/monster_test.bfbs
index 41d9edb..66d3ee8 100644
--- a/tests/monster_test.bfbs
+++ b/tests/monster_test.bfbs
Binary files differ
diff --git a/tests/monster_test_generated.js b/tests/monster_test_generated.js
index 774882d..6789ebb 100644
--- a/tests/monster_test_generated.js
+++ b/tests/monster_test_generated.js
@@ -693,7 +693,7 @@
  */
 MyGame.Example.Monster.prototype.inventoryArray = function() {
   var offset = this.bb.__offset(this.bb_pos, 14);
-  return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
+  return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
 };
 
 /**
@@ -839,7 +839,7 @@
  */
 MyGame.Example.Monster.prototype.testnestedflatbufferArray = function() {
   var offset = this.bb.__offset(this.bb_pos, 30);
-  return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
+  return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
 };
 
 /**
@@ -1080,7 +1080,7 @@
  */
 MyGame.Example.Monster.prototype.testarrayofboolsArray = function() {
   var offset = this.bb.__offset(this.bb_pos, 52);
-  return offset ? new Int8Array(this.bb.bytes().buffer, this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
+  return offset ? new Int8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
 };
 
 /**