when you say That would be like doing return count - 1 . Evaluating the result (the value) and returning it. im reading that and thinking yes so count = 0 so count - 1 = count (0) -1 so the answer should be -1. there must be a mistake in how I am thinking about that. could you elaborate on - evaulating the result(the value) please
seems very odd that if you have a function like this
let count = 10
function decrease () {
return count --
}
console.log(decrease())
it doesnt really do anything, just returns the original value
what I meant was, is there someway you could you then use the decremented value ? from my view it returns the original value and then function exits so decrementing after the return does not seem useful or is there a good use for that ?
Sure, you can just use count, not the return value of the function. But it’s just an example – if you use the postfix version of decrement, then the current value gets returned, and doing it like this makes it explicit – that’s all it is.