[Javascript]promiseのonFulfilled、onRejected

promiseのonFulfilled、onRejected

<apex:page>
    <html>

        <head>

        </head>

        <body>

            <script type="text/javascript">

                const resolvedProm = Promise.resolve(33);

                let thenProm = resolvedProm.then(value => {
                    console.log("this gets called after the end of the main stack. the value received and returned is: " + value);
                    return value;
                });
                // instantly logging the value of thenProm
                console.log(thenProm);

                // using setTimeout we can postpone the execution of a function to the moment the stack is empty
                setTimeout(() => {
                    console.log(thenProm);
                });
                
            </script>

        </body>

    </html>
</apex:page>

結果

投稿者: kinkun

保有資格 Salesforce Certified Platform App Builder T Salesforce Certified Platform Developer I Salesforce Certified Platform Developer II Salesforce Certified Administrator

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です