Skip to content

Commit 4cbf9cf

Browse files
update to internal commit 57595b2c
1 parent 5aabd5d commit 4cbf9cf

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

programming/javascript/user-guide/barcode-scanner.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ If you are fully satisfied with the solution and would like to move forward with
8080
(async () => {
8181
// Launch the scanner and wait for the result
8282
const result = await barcodeScanner.launch();
83-
alert(result.barcodeResults[0].text);
83+
// Display the first detected barcode's text in an alert
84+
if (result.barcodeResults.length) {
85+
alert(result.barcodeResults[0].text);
86+
}
8487
})();
8588
</script>
8689
</body>
@@ -210,7 +213,10 @@ const barcodescanner = new Dynamsoft.BarcodeScanner({
210213
(async () => {
211214
// Launch the scanner and wait for the result
212215
const result = await barcodescanner.launch();
213-
alert(result.barcodeResults[0].text);
216+
// Display the first detected barcode's text in an alert
217+
if (result.barcodeResults.length) {
218+
alert(result.barcodeResults[0].text);
219+
}
214220
})();
215221
```
216222

0 commit comments

Comments
 (0)