class Calculator {
constructor(firstValue, secondValue) {
if (Number.isSafeInteger(firstValue) && Number.isSafeInteger(secondValue)){
this.firstValue = firstValue
this.secondValue = secondValue
} else {
throw new Error ('Ошибка');
}
}
setX(num) {
this.firstValue = num;
}
setY(num) {
this.secondValue = num;
}
logSum() {
console.log(this.firstValue + this.secondValue);
}
logMul() {
console.log(this.firstValue*this.secondValue);
}
logSub() {
console.log(this.firstValue - this.secondValue);
}
logDiv() {
console.log(this.firstValue/this.secondValue);
}
}
let user = {
name: "John",
money: 1000,
[Symbol.toPrimitive](hint) {
alert(`hint: ${hint}`);
return hint == "string" ? `{name: "${this.name}"}` : this.money;
}
};
// демонстрация результатов преобразований:
alert(user); // hint: string -> {name: "John"}
alert(+user); // hint: number -> 1000
alert(user + 500); // hint: default -> 1500
<ul class="personal__inform">
<li class="personal__status ">
<p class="personal__descr">Buyer Power <br> $15.546 </p>
</li>
<li class="personal__status ">
<p class="personal__descr">Watchlist <br>12</p>
</li>
<li class="personal__status">
<p class="personal__descr">Bids Status <br>0 1 </p>
</li>
<li class="personal__status">
<p class="personal__descr ">Hello, <span> Jonh</span></p>
</li>
</ul>