Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Uncaught ReferenceError: Cannot access 'date' before initialization

sorry to bother u but i can’t get my mistake in the following code, that makes me getting this "Cannot access ‘date’ before initialization", Any help is much appreciated. Thanks.

    document.querySelector('a').addEventListener('click', function () {
        let date = new date(date.now() + 86400000);
        date = date.toUTCString();
        document.cookie = 'acceptsCookies=true; path=/; expires=' + date;
    });

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

It should be Date not date

let date = new Date(Date.now() + 86400000);

The interpreter thinks, that you use the date variable.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading