Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING BASH RUST

Basic JavaScript

JS Tutorial JS Syntax JS Variables JS Operators JS If Conditions JS Loops JS Strings JS Numbers JS Functions JS Objects JS Dates JS Arrays JS Typed Arrays JS Sets JS Maps JS Math JS RegExp JS Data Types JS Errors JS Events JS Programming JS References JS UTF-8 Characters JS Versions

JS Advanced

JS Functions JS Objects JS Classes JS Iterations JS Asynchronous JS Modules JS HTML DOM JS Windows JS Web API JS AJAX JS JSON JS jQuery JS Graphics JS Examples JS Reference


JavaScript 1999 (ES3)

ECMAScript 3 (1999)

The first revision to JavaScript.

ECMAScript 1999 is also known as ES3.

ES3 Features

FeatureDescription
Regular expressions Sequence of characters that forms a search pattern
Error handling (try...catch) Statement to define code blocks to be tested in case of an error
The switch keyword Selects code blocks to be executed based on a conditions
The do...while loop A variant of the while loop

Browser Support

JavaScript 1999 is supported in all browsers:

Chrome IE/Edge Firefox Safari Opera

Regular Expressions

A sequence of characters that forms a search pattern.

Example

Do a case-insensitive search for "w3schools" in a string:

let text = "Visit W3Schools";
let n = text.search(/w3schools/i);

Try it Yourself »


The try...catch Keywords

Statement to define code blocks to be tested in case of an error.

Examples

You cannot use a non-existing variable:

let x = 5;

try {
  x = y + 1;
} catch(err) {
  let text = err.name;
}
Try it Yourself » Learn More ...

The switch Keyword

Based on a condition, switch selects one or more code blocks to be executed.

Example

This example uses the weekday number to calculate the weekday name:

switch (new Date().getDay()) {
  case 0:
    day = "Sunday";
    break;
  case 1:
    day = "Monday";
    break;
  case 2:
     day = "Tuesday";
    break;
  case 3:
    day = "Wednesday";
    break;
  case 4:
    day = "Thursday";
    break;
  case 5:
    day = "Friday";
    break;
  case 6:
    day = "Saturday";
}
Try it Yourself » Learn More ...

The do...while Loop

The do while runs at least once, even if the condition is false from the start.

This is because the code block is executed before the condition is tested:

Example

do {
  text += "The number is " + i;
  i++;
}
while (i < 10);
Try it Yourself » Learn More ...

Note

Do not forget to increase the variable used in the condition, otherwise the loop will never end!


×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2025 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.