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

305
Vistas
Nextjs: static class / use function

I want to create tools class/function in nextjs

I have 2 ways for this.

With static class:

class Tools {
    static titleCase(value: string) {
        return value.charAt(0).toUpperCase() + value.slice(1).toLowerCase();
    }
}

export default Tools

With use function:

export default function Tools(){
    function titleCase(value: string) {
        return value.charAt(0).toUpperCase() + value.slice(1).toLowerCase();
    }

    return { titleCase }
}

And here is my question:

1- Which is better?

2- What is difference between these?

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

0

Neither. The better solution for static utility functions is to use named exports:

// tool.js:
export function titleCase(value: string) {
    return value.charAt(0).toUpperCase() + value.slice(1).toLowerCase();
}

Shorter, no unnecessary intermediate objects, and good for tree-shaking.

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