JavaScript Versions — ECMAScript 3(1999)

Logismiko
3 min readFeb 12, 2023

--

ECMAScript 3 (ES3) was released in 1999 and is widely considered to be the version of JavaScript that defined the language for the web. In this article, we’ll explore the features and capabilities of ECMAScript 3, along with code examples.

The main goal of ES3 was to standardize the language and provide a solid foundation for web developers. ES3 introduced several new features and enhancements that made the language more powerful, more efficient, and more flexible.

New Features in ECMAScript 3:

Regular Expressions

ES3 added support for regular expressions, which are powerful tools for searching and manipulating text. Regular expressions use a special syntax to define a pattern that can be used to match or replace specific characters or character patterns.

// Test if a string contains a valid email address
var email = "john.doe@example.com";
var pattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (pattern.test(email)) {
console.log("Valid email address");
} else {
console.log("Invalid email address");
}

try/catch

ES3 introduced a new error-handling mechanism called try/catch. This mechanism allows developers to catch errors and handle them in a more graceful way, preventing the application from crashing or displaying error messages to the user.

try {
// Try to execute some code that might generate an error
var num = 10 / 0;
} catch (e) {
// Handle the error gracefully
console.log("An error occurred: " + e.message);
}

JSON

ES3 introduced the JSON (JavaScript Object Notation) data format. JSON is a lightweight data format that is easy to read and write, making it an ideal choice for data exchange between client and server applications.

// Convert an object to JSON
var person = {
"name": "John Doe",
"age": 30
};
var json = JSON.stringify(person);
// Convert JSON to an object
var person = JSON.parse('{"name":"John Doe","age":30}');

Enhanced Object Literals

ES3 introduced enhanced object literals, which allowed developers to define object properties in a more concise and readable way. This feature also made it easier to define methods for objects.

// Define an object using enhanced literals
var person = {
name: "John Doe",
age: 30,
sayHello() {
console.log("Hello, my name is " + this.name + ".");
}
};
// Call the object's method
person.sayHello();

Function Expressions

ES3 introduced function expressions, which allow functions to be defined as expressions and assigned to variables. This feature made it easier to define functions on the fly and pass them as arguments to other functions.

// Define a function expression
var add = function(x, y) {
return x + y;
};
// Call the function
var result = add(2, 3);
console.log(result);

Conclusion

ECMAScript 3 was a major milestone in the development of the JavaScript language. Its features and enhancements laid the foundation for the powerful and flexible language that we know today. Many of the features introduced in ES3 are still in use today, including regular expressions, try/catch, and JSON. If you’re just getting started with JavaScript, it’s important to understand the features and capabilities of ES3, as it will provide a strong foundation for your understanding of the language. ES3 also served as the basis for many of the JavaScript frameworks and libraries that we use today, such as jQuery and React.

While ES3 was a significant step forward for JavaScript, it did have some limitations. For example, it did not provide support for the let and const keywords, which are used for declaring variables with block scope. It also did not include some of the more advanced languages features that we have today, such as arrow functions and classes.

Nonetheless, ES3 remains an important part of the history and evolution of JavaScript, and its features and capabilities are still widely used today. If you’re looking to develop a deeper understanding of the language, it’s important to study the features and enhancements of ES3, as they provide a foundation for the advanced features that we have today.

--

--

Logismiko

Logismiko - The Next-Generation software development studio. We have clients from all over the world, who trust us with their business identity and image.