[MISC] Why do inc/deinc operators not work after arrays
Was fiddling around with some JS arrays today -
Code:
<script type="text/javascript">
var counter = 0;
function pLog(arg) {
console.log(++counter + ": " + typeof(arg) + "(" + arg + ")");
}
pLog(["1"][0]); //string(1)
pLog(++["1"][0]); //number(2)
pLog(--["1"][0]); //number(0)
pLog(["1"][0]--); //number(1)
pLog(["1"][0]++); //number(1)
</script>
Why do the inc/deinc operators cast the value to a number but not change it when they're placed after the array?