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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:03:46+00:00 2026-06-02T18:03:46+00:00

Code of horror: var namespace = new function () { this.saySomething = new function(

  • 0

Code of horror:

var namespace = new function ()
{
    this.saySomething = new function( something )
    {
        console.log( something );
    };
}

namespace.saySomething( "whatever" );

This outputs “undefined” when I expected it to output “whatever”. How come? And what would the fix be? My goal is nothing more than to have a namespace where I put some helper functions.

  • 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-02T18:03:46+00:00Added an answer on June 2, 2026 at 6:03 pm

    You don’t need to use new before the functions. new is only used for instantiating objects, when a constructor is already defined.

    Your code should look like:

    var namespace = {
        saySomething: function(something) {
            console.log(something);
        }
    }
    
    namespace.saySomething("whatever");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

code 1 $(document).ready(function() { $('.poem-stanza').addClass('highlight'); }); code 2 $(document).ready( $('.poem-stanza').addClass('highlight'); );
Code: var result = db.rows.Take(30).ToList().Select(a => AMethod(a)); db.rows.Take(30) is Linq-To-SQL I am using ToList()
I have try this code on DatabaseHelper.java Line Number 34 public DatabaseHelper(Context context) throws
I'm new to VB6 but i'm currently in charge of maintaining a horror of
Once, there was this awesome SNIPPETS library of C (and C++) code. I used
Code would explain this much better :) def a(): x=0 def b(z=x): print(X: %d,
Code that was working fine last week is suddenly throwing this exception: System.Data.SqlClient.SqlException (0x80131904):
I discovered the FizzBuzz question today at coding horror . Great article. However, something
Code: ArrayList <Integer> marks = new ArrayList(); private void addButtonActionPerformed(java.awt.event.ActionEvent evt) { Collections.addAll(marks, (Integer.parseInt(markInput.getText())));
Code 1: ArrayList arr = new ArrayList(); arr.add(3); arr.add(ss); Code 2: ArrayList<Object> arr =

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.