function palindrome(num) { var tmp = num, res = 0, dig; while (tmp) { dig = tmp % 10; res = res * 10 + dig; tmp = (tmp - dig) / 10; } return res == num; } alert(palindrome(123321));