Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8055973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:34:07+00:00 2026-06-05T08:34:07+00:00

Im having hard time to understand why this thing doesnt work. where is the

  • 0

Im having hard time to understand why this thing doesnt work. where is the problem? Is this the right way to pass in values to this function, are there other ways?

seqer.set_prefix = ‘Q’;
seqer.set_seq = 1000;

Is it possibleto do it in this way:

sequer.set_prefix('Q');

var serial_maker = function () {
        var prefix = '';
        var seq = 0;
        return {
            set_prefix: function (p) {
                prefix = p;
            },
            set_seq: function (s) {
                seq = s;
            },
            gensym: function () {
                var result = prefix + seq;
                seq += 1;
                return result;
            }
        };
    }();
var seqer = serial_maker();
seqer.set_prefix = 'Q'; // is this the right way to pass in values to this function, are there other ways? is it possible to write like this sequer.set_prefix('Q);
seqer.set_seq = 1000; // same here?
seqer.gensym()

;

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T08:34:08+00:00Added an answer on June 5, 2026 at 8:34 am

    Anonymous functions are first-class citizens in JavaScript – you can generally treat them exactly like you would treat a normal function (except that they have no given identifier, unless you assign them to a name). Here’s a good tutorial about them – they are quite powerful, and I consider them to be one of the best things about JavaScript.

    So yes, doing:

    seqer.set_prefix = 'Q';
    seqer.set_seq = 1000;
    

    is incorrect. You are overwriting the funcitons with these constants. Your guess is correct – to call them, you would use:

    seqer.set_prefix('Q');
    seqer.set_seq(1000);
    

    By the way, there is another error in your function:

    var serial_maker = function () {
            ...
            return {
                ...
            };
        }(); // <- right here
    

    You’re defining an anonymous function, but calling it immediately. So unfortunately, var serial_maker won’t be a serial_maker – it’ll be the returned object. Of course, the subsequent var seqer = serial_maker(); will fail, because the object is not a function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a hard time following this function. I do not understand how
I am having a hard time describing this in a way Google will understand.
I'm having hard time with this simple ajax call function sendreq() { $.ajax({ dataType:
Having a hard time figuring out the best way to do this... I have
I'm having a hard time understanding why there is only one test per function
I am having a hard time understanding the nuances of git-fetch. I understand that
I am having hard time getting hasErrors to work with indexed properties. For example
I am having hard time finding a way to display a loading image in
I am having hard time digesting this syntax: void* operator new[](std::size_t, const std::nothrow_t&) throw();
I'm having a hard time understanding what I'm supposed to do. The only thing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.