Loading lesson path
ECMAScript 3 (1999) The first revision to JavaScript. ECMAScript 1999 is also known as ES3.
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
Selects code blocks to be executed based on a conditions The do...while loop
JavaScript 1999 is supported in all browsers:
A sequence of characters that forms a search pattern.
Formula
Do a case - insensitive search for "w3schools" in a string:let text = "Visit W3Schools";
let n = text.search(/w3schools/i);Learn More ... The try...catch Keywords Statement to define code blocks to be tested in case of an error.
Formula
You cannot use a non - existing variable:let x = 5;
try {
x = y + 1;
} catch(err) {
let text = err.name;
}Learn More ...
Based on a condition, switch selects one or more code blocks to be executed.
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";
}Learn More ... The do...while
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);Learn More ... Do not forget to increase the variable used in the condition, otherwise the loop will never end!