function test(a) { a = a.toString(2); if (a.length % 2) a = '0' + a; a = [...a]; for (; a.length;) if (a.pop() != a.shift()) return false; return true } console.log(test(129))