JAVASCRIPT Telegram 2244
CHALLENGE

const privateData = new WeakMap();

function Person(name) {
privateData.set(this, { name, secretCount: 0 });

this.greet = function() {
const data = privateData.get(this);
data.secretCount++;
return `Hello, my name is ${data.name}`;
};

this.getSecretCount = function() {
return privateData.get(this).secretCount;
};
}

const alice = new Person('Alice');
alice.greet();
alice.greet();

const result = [
privateData.has(alice),
alice.name,
alice.getSecretCount()
];

console.log(result);
👍41



tgoop.com/javascript/2244
Create:
Last Update:

CHALLENGE

const privateData = new WeakMap();

function Person(name) {
privateData.set(this, { name, secretCount: 0 });

this.greet = function() {
const data = privateData.get(this);
data.secretCount++;
return `Hello, my name is ${data.name}`;
};

this.getSecretCount = function() {
return privateData.get(this).secretCount;
};
}

const alice = new Person('Alice');
alice.greet();
alice.greet();

const result = [
privateData.has(alice),
alice.name,
alice.getSecretCount()
];

console.log(result);

BY JavaScript


Share with your friend now:
tgoop.com/javascript/2244

View MORE
Open in Telegram


Telegram News

Date: |

Channel login must contain 5-32 characters Developing social channels based on exchanging a single message isn’t exactly new, of course. Back in 2014, the “Yo” app was launched with the sole purpose of enabling users to send each other the greeting “Yo.” A Hong Kong protester with a petrol bomb. File photo: Dylan Hollingsworth/HKFP. Telegram users themselves will be able to flag and report potentially false content. Telegram desktop app: In the upper left corner, click the Menu icon (the one with three lines). Select “New Channel” from the drop-down menu.
from us


Telegram JavaScript
FROM American