devxlogo

Converting VBScript to JavaScript

Converting VBScript to JavaScript

Question:
I need to convert this fairly simple VBScript to a JavaScript? The purpose of the script is to cause a posted seminar event to disappear after the date of the event has passed. Here is my code:

Answer:
Here’s how I’d do it:

If you're wondering about the way eventDate is initialized (and who could blame you?), it's due to the way JavaScript works with dates. The month is zero-relative, but everything else is one-relative. Intuitive, huh?

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist