Skip to content

Editorial: small cleanup of examples#263

Open
marcoscaceres wants to merge 2 commits into
mainfrom
marcoscaceres-patch-1
Open

Editorial: small cleanup of examples#263
marcoscaceres wants to merge 2 commits into
mainfrom
marcoscaceres-patch-1

Conversation

@marcoscaceres
Copy link
Copy Markdown
Member

@marcoscaceres marcoscaceres commented Nov 22, 2023

Use async/await in both examples. Use nullish coalescing.


Preview | Diff

Use async/await in both examples. Use nullish coalescing.
Comment thread spec.bs Outdated
Comment thread spec.bs
PaymentRequest &&
PaymentRequest.isSecurePaymentConfirmationAvailable &&
await PaymentRequest.isSecurePaymentConfirmationAvailable();
await PaymentRequest?.isSecurePaymentConfirmationAvailable();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is cool, I've never seen it before!

I think it's technically optional chaining (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining) rather than nullish coalescing (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing), right?

Does this work as written if PaymentRequest itself is not defined? (As opposed to isSecurePaymentConfirmationAvailable not being defined). It seemed not when I tried it in Firefox, but I may have been holding it wrong. I had to do:

window.PaymentRequest?.isSecurePaymentConfirmationAvailable();

Without the window, I just got:

PaymentRequest?.isSecurePaymentConfirmationAvailable()
Uncaught ReferenceError: PaymentRequest is not defined
    <anonymous> debugger eval code:1
debugger eval code:1:1

@AKJUS
Copy link
Copy Markdown

AKJUS commented Jul 10, 2025

AKJUS updates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants