Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- 'use strict'
- {
- let BaseInstance;
- class Base {
- constructor(id) {
- // this = new Object();
- // this = {};
- this._id = id;
- if (!BaseInstance) {
- BaseInstance = this;
- }
- return BaseInstance;
- }
- getId() { return this._id };
- print() { console.log(`Hello, from Base class with id: ${this._id}`); };
- }
- }
- {
- let bc1 = new Base(1);
- let bc2 = new Base(2);
- let bc3 = new Base(3);
- bc1.print();
- bc2.print();
- bc3.print();
- console.log(`Are objects differ? : ${bc1 != bc2}`);
- console.log(`Are objects differ? : ${bc2 != bc3}`);
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement