Skip to main content

Gist baa8565f0ec238a1d9fccefd15baf53a

✓ Published0🌍 Public
Aabernier
Last edited Sep 12, 2016
Created on Sep 12, 2016

This example demonstrates a minimal JavaScript module system in action, showing how a Car class with a color property and a counter is imported and used. The code defines a Car constructor function that initializes a red car by default, with a `roule` method that increments the counter by the given kilometers. A separate file requires the Car module, creates a green car instance named titine, and calls `roule(5)` to add five kilometers to its counter. The example relies on Node.js’s `require` and `module.exports` APIs to handle module loading and export.

AI-generated description