Need to learn some javascript codes!! Would you help me?

pos += 1 will increment the variable pos by 1, and return it.

pos = +1 is the same as saying pos = 1. The plus is redundant.

See it in action with this simple script:

pos1 = 10;
pos2 = 10;

pos1 += 1;
pos2 =+ 1;

console.log('pos1', pos1);
console.log('pos2', pos2);

Leave a Comment