JavaScript - How calculator type numeric buttons work in JavaScript