Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

183
Views
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 answers
Answer question

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 Report

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 Report

0

you can pass a value to a function

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

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!