SOURCE

/**
 * @param {number} x
 * @return {boolean}
 */
var isPalindrome = function(x) {
//     if (x<0) return false;
//     var n=parseInt(Math.log(x)/Math.log(10))
//     for(;;){
//         if(x<=0)break;        
        
//         var a=parseInt(x/Math.pow(10,n));
//         var b=x%10;
//         //console.log(n);
//         //console.log(a,b);
//         if(a!=b)return false;
//         x=(x-a*Math.pow(10,n)-b)/10;        
//         //console.log(x)
//         n=n-2;
//     }
//     return true;   
  
		if (x < 0) {
        return false
    }
    if (x < 10) {
        return true
    }
    let reverse = 0;
    let copyx = x;
    while (copyx > 0) {
        reverse = reverse*10 + copyx % 10
        copyx = (copyx - copyx%10)/10
    }
    return x === reverse
};
console.log(isPalindrome(0));
console.log(isPalindrome(121));
console.log(isPalindrome(23));
console.log(isPalindrome(10021));
console.log(isPalindrome(1001));
console 命令行工具 X clear

                    
>
console