I am learning Javascript. I am trying to convert Object. While trying to convert it's only printing Number not string. while printing string it shows complete object not string. Below is my code.
let user2 = {
name: "Akash",
surName: "Jangra",
age: 30,
Salary: 25000,
[Symbol.toPrimitive](hint) {
console.log(`hint : ${hint}`);
return hint == "string" ? `{name: "${this.name}"}, ${this.surName}` : this.Salary;
}
};
console.log(user2);
console.log(+user2);
console.log(user2 + 500);