Get started with augment CDN
MIT licensed
Augment is a library that provides a simple way to add new methods and properties to existing objects.
Tags:- augment
- augments
- augmentation
- extend
- extends
- extension
- prototype
- prototypal
- class
- classical
- object
- inheritance
- uber
- super
- constructor
- oop
Stable version
Copied!
How to start using augment CDN
// Include the augment library
const Augment = require('augment-compat'); // For Node.js
// or
// <script src="https://cdn.cdnhub.io/augment/4.3.1/augment.min.js"></script> // For the browser
// Define a base class
class Base {
constructor() {
this.value = 0;
}
increment() {
this.value++;
}
}
// Augment the base class with a new method
Augment(Base).methods('double', function() {
this.value *= 2;
});
// Create an instance of the base class and test the new method
const myInstance = new Base();
myInstance.increment();
myInstance.double();
console.log(myInstance.value); // Output: 4
Copied!
Copied!
Copied!