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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:54:12+00:00 2026-05-13T11:54:12+00:00

In my feeble attempt to learn JavaScript, I bought a book which teaches you

  • 0

In my feeble attempt to learn JavaScript, I bought a book which teaches you how to do things in JavaScript, but forgets to mention WHY.

Coming from PHP I am familiar with the typical function syntax:

function name() {return;}

which from what I understand works the same in JS.

Then I decide I want to attempt to use the YUI 3 framework for a small project to continue learning and come across this…YUI Global Object

YUI().use('node', function(Y) {
   Y.Node.get('#demo');
});

As far as I understand this is using the ‘use’ function of the YUI() object, passing ‘node’ to the ‘use’ function….but then what…why is it declaring a function within another function call?

Could someone please explain the syntax being used here?

Also a good reference that explains JavaScript general syntax’s similar to php.net would also be beneficial.
Thanks for your help.

  • 1 1 Answer
  • 1 View
  • 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-13T11:54:13+00:00Added an answer on May 13, 2026 at 11:54 am

    Its an anonymous function. Its considered a callback.

    In PHP 4 and early versions of PHP 5 you might see something like this:

    PHP

    function callback($var){
       ...
    }
    
    array_filter( $array, "callback" );
    

    In later versions of PHP 5 you can define them as anonymous functions inline.

    So, in JavaScript, the old version would look like this:

    JavaScript

    function use_callback(Y){
        Y.Node.get('#demo');
    }
    
    YUI().use('node', use_callback);
    

    But by defining an inline anonymous function, you can save the extra clutter and defined function:

    YUI().use('node', function(Y) {
       Y.Node.get('#demo');
    });
    

    Both those functions are equivalent.

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

Sidebar

Related Questions

In my feeble attempt to write better Model methods, I am failing hard. Which
My feeble attempt at an A* Algorithm is generating unpredictable errors. My FindAdjacent() function
Edited in a feeble attempt to clarify. The system converts XML into another XML
I want to color hline, e.g.: \hline[color=red,width=2mm,dashed] or something. Below is a feeble attempt
I have the function below which I call very frequently in a loop. I
Currently my domain foo.com is handled by the wsgi script, but I require urls
I have this as a test harness: <html> <script src=jquery-1.7.1.min.js></script> <script src=jquery-ui-1.8.18.custom.min.js></script> <script type=text/javascript>
I installed Python 2.7 on my mac from source. Before, I could use the
I've received much excellent instruction on Stack Overflow, especially regarding my feeble attempts to
I have YAML data that looks sort of like this, but ~150k of it:

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.