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 4019686
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:08:06+00:00 2026-05-20T10:08:06+00:00

I wrote the following function as a part of a jQuery plugin I am

  • 0

I wrote the following function as a part of a jQuery plugin I am developing:

$.fn.append2 = function(collection, callback) {
    var $this = this;

    $.each(collection, function(key, value) {
        $this.append(callback ? callback(key, value) : value);
    });

    return this;
};

After testing a highly recursive function that heavily depended on .append2, I optimized .append2 to:

$.fn.append2 = function(collection, callback) {
    var $this = this;

    $.each(collection, callback
        ? function(key, value) { $this.append(callback(key,value)); }
        : function(key, value) { $this.append(value); }
    );

    return this;
};

While this code is more efficient in terms of speed, it still left me unsatisfied. I have, essentially, defined the same function twice:

function(key, value) { $this.append(callback(key,value)); }
function(key, value) { $this.append(value); }

And I wondered if there is any language that lets me defined the function only once as:

function(key, value) { $this.append(value); }

And then operate on it by replacing the argument to $this.append from value to callback(key, value). (And, no, not by manipulating strings. By manipulating the function itself.)

Is there any such programming language?

  • 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-05-20T10:08:07+00:00Added an answer on May 20, 2026 at 10:08 am

    Any homoiconic language lets you do this do some degree or another. All of the Lisp languages let you build functions procedurally out of bits and pieces and then invoke them as normally. The Io language is rare in that I believe it will let you go the other way: given a function, you can pull apart its source code and manipulate it.

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

Sidebar

Related Questions

I am using jQuery Validation Plugin (http://bassistance.de/jquery-plugins/jquery-plugin-validation/) I have wrote following rule jQuery.validator.addMethod(valueNotEquals, function(value,
Have a look at the following code (additionally, you will need jquery.js , jquery.viewport.js
I have a table with the following data: NodeId ExternalIds 50 601 56 700,701
I wrote the code using dojo where it shows on the screen two inputs
I am having quite a tricky problem, which i just cannot seem to solve.
I have a quite difficult problem with binary files. I have been asked to
I am facing a problem in my application. I have some section in application
I'm a beginner at XSL FO. I have a very simple XML document :
I've been studying rvalue references lately and came to a conclusion that it's quite
I'm new to c++ . I want to know about object pointer and pointer

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.