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

185
Vistas
Function(dot)value [Javascript]

How do i create a function with a value after it?

e.g

function gotolocation(href) {
    href = href + "?search=stackoverflow";
    window.location = href;
}

gotolocation.href = "https://google.com";

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

0

You could use Setter

const gotolocation = {
  set href(url) {
    url += "?search=stackoverflow";
    window.location = url;
  }
};

gotolocation.href = "https://google.com";

but in such case gotolocation would be an Object with a Setter function bound to the href property, not a function per-se.


If your question was: "How to use this function"
than the answer is simple: your function accepts one argument, so pass one:

gotolocation("https://google.com");
about 4 years ago · Juan Pablo Isaza Denunciar

0

You can create an object with function, like class in OOP;

const location = {
   href: "https://facebook.com",
   goto: () => {
      let link = location.href + "?search=stackoverflow";
      window.location = link;
   }
}

location.href = "https://google.com";

location.goto();
about 4 years ago · Juan Pablo Isaza Denunciar

0

you can pass a value to a function

gotolocation("https://google.com");

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