I want to increase object value just like loop i++ , but in object didnt worked , how to increase this value ? any methods?
const object = {
price:30
}
console.log(object.price++);
I want to increase object value just like loop i++ , but in object didnt worked , how to increase this value ? any methods?
const object = {
price:30
}
console.log(object.price++);
using ++ like that is the post-increment operator meaning object.price++ returns object.price first then increments. You want the pre-increment operator ++object.price.
const object = {
price:30
}
console.log(++object.price);