4. You want to print the incremental count each time you instantiate a object using new in JS
class Key {
// The static property
static lastKey = 0;
// The instance property using the class fields proposal syntax
// Note I didn't initialize it with 1, that's a bit misleading.
key;
constructor() {
// Increment and assign
this.key = ++Key.lastKey;
}
print_key() {
console.log(this.key)
}
}
const key1 = new Key();
const key2 = new Key();
const key3 = new Key();
key1.print_key();
key2.print_key();
key3.print_key();
Also in JavaScript:
- js select all
- how to connect mongoose to node js
- export component in
- strapi cloudinary how to use
- add firebase in react
- eslint ignore javascript
- js string to array
- object values
- exercism.io bob solution
- fortuna based rng js
- react copy to clipboard
- jquery get img src
- json parse string
- create server and connect to db and frontend
- accèder data-id javascript
- react native webview postmessage example
- how to iterate through an array in javascript
- secure random nodejs
- select option trigger in js
- javascript get selected option
- type explicit conversion js
- fetch api with express
- how to name a javascript variable
- functional component react with state