[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>

結果

[Javascript]promiseのthen,reason

promiseのthen,reason

<apex:page>
    <html>

        <head>

        </head>

        <body>

            <script type="text/javascript">

                const promise1 = new Promise((resolve, reject) => {
                resolve('Success!');
                });

                promise1
                .then((value) => {
                    console.log(value);
                    // expected output: "Success!"
                }
                ,reason => {
                    console.log("Error!");
                });
                
            </script>

        </body>

    </html>
</apex:page>

[Javascript]Javasriptでtomorrow取得

Javasriptでtomorrow取得

            const today = new Date();
            
            const tomorrow = new Date(today);
            tomorrow.setDate(tomorrow.getDate() + 1);

            const yyyyTomorrow = tomorrow.getFullYear();
            let mmTomorrow = tomorrow.getMonth() + 1;
            let ddTomorrow = tomorrow.getDate();
            const yyyymmddTomorrow = yyyyTomorrow + "," + mmTomorrow + "," + ddTomorrow;
            console.log('yyyymmddTomorrow:'+yyyymmddTomorrow);

            var endDate = new Date(yyyymmddTomorrow);
            console.log('endDate:'+endDate);