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

  • Home
  • SEARCH
  • 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 9188779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:05:40+00:00 2026-06-17T20:05:40+00:00

I was browsing through the jade templating engine source code and I am trying

  • 0

I was browsing through the jade templating engine source code and I am trying to figure out what this statement means.

I get that it’s going to try and instantiate options.compiler and if that fails instantiate Compiler, but the next part confuses me… Is this saying to call parser.parse and declare the returned value as a variable? If so, why is the rightmost paren around options?

var compiler = new (options.compiler || Compiler)(parser.parse(), options)
  , js = compiler.compile();

.
Here’s some more context if that helps

function parse(str, options){
  try {
    // Parse
    var parser = new Parser(str, options.filename, options);

    // Compile
    var compiler = new (options.compiler || Compiler)(parser.parse(), options)
      , js = compiler.compile();

Github – Line 960

  • 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-17T20:05:41+00:00Added an answer on June 17, 2026 at 8:05 pm

    Let’s break it down.

    (options.compiler || Compiler)
    

    This expression seems to be designed to look for a “class” (well, technically a constructor function, this being JavaScript). The options object may be used to specify it, or else it will fall back to whatever is referenced by Compiler.

    new (options.compiler || Compiler)(/* ... */)
    

    Okay, now this makes more sense. We’re invoking a constructor. It’s just that the “class” was chosen dynamically.

    new (options.compiler || Compiler)(parser.parse(), options)
    

    When we income the constructor, we’re passing in two parameters. The first is the result of calling the parse method of the parser object, and the second is the options object from earlier.

    var compiler = new (options.compiler || Compiler)(parser.parse(), options)
    

    That unholy mess is stored in the compiler variable.

    var compiler = new (options.compiler || Compiler)(parser.parse(), options), js = compiler.compile();
    

    You can declare and assign multiple variables in the same var statement, so that confuses things further. But the last part is pretty easy to understand by itself.

    That statement could, and probably should, be broken down into multiple lines… but it is what it is.

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

Sidebar

Related Questions

Browsing through the source code of Microsoft's sample StockTrader application, I found this snippet
After browsing through this site, I found that you can get Yahoo weather in
I'm browsing through the Zepto source code and there is this little function here:
I am browsing through Flamejs' source code and am seeing this a lot: Flame
As I'm browsing through a Rails source code, it contains the line: @@autoloads =
I'm trying to get rid of some hints(*) the Delphi compiler emits. Browsing through
I've been browsing through the documentation, but I can't seem to figure out a
While browsing through the source code of the java.util.concurrency package, I noticed an idiomatic
Hi all I was browsing through some of the Java source code when I
While browsing through source code in my IDE I'll sometimes wish I could see

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.