Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

175
Vistas
How can i simplify a oneliner javascript code like this

I was recently converting an obfuscated js code to python I'm not good at js when I saw this I had no clue what to do is there anyway to convert this to simple js code

return 12 === selector ? (data = data >> 4, outstring = outstring + String.fromCharCode(data)) : 18 === selector && (data = data >> 2, outstring = outstring + String.fromCharCode((65280 & data) >> 8), outstring = outstring + String.fromCharCode(255 & data)), outstring;

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Here is somewhat simplified version of your code:

if (selector === 12) {
  data = data >> 4; // or data = Math.floor(data / 16), which is do right shift operation with data by 4 bits; 16 means 2 to the power of 4
  outstring += String.fromCharCode(data); // append char value of data
  return outstring;
} else if (selector === 18) {
  data = data >> 2;
  outstring = outstring + String.fromCharCode((65280 & data) >> 8); // turn higher 8 of 16 bits to a character and append
  outstring = outstring + String.fromCharCode(255 & data); // turn lower 8 of 16 bits to a character and append
}
return outstring;

If you are completely new to JS, you will probably find links String.fromCharCode() and Right shift (>>) helpful

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda