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

124
Vistas
Why does summation of string and number output a string but multiplication of them output a number in javascript?

string + number

const a = "5";
const b = 7;

console.log(a + b);

Output is - 57


string * number

const a = "5";
const b = 7;

console.log(a * b);

Output is - 35

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

0

it's based on what the creators of JS thought would be more useful. In every other language you can concatenate the strings, numbers and other stuff using the +. So in JS they thought that would be a nice solution as well. But then... what does it mean to multiply a string? The creators of JS had no answer, so assumed this must be a mathematical operation.

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