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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:13:05+00:00 2026-05-24T16:13:05+00:00

I ended up with this code in one of my projects: function foo(type, desc)

  • 0

I ended up with this code in one of my projects:

function foo(type, desc)
{
  var p = new type(desc);
}

I am not an expert in JS, can somebody confirm whether it’s valid JavaScript or not? It seems to be working fine, with Chrome at least.

type – is a class that is derived from another class, has some functions.
desc – is just an object that keeps properties.

update: yes, type is a constructor: function type(desc) {}

  • 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-24T16:13:07+00:00Added an answer on May 24, 2026 at 4:13 pm

    assuming var type = function(foo){...} then yes

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

Sidebar

Related Questions

I ended up with this horrible code below, I can't get a better result
This question is a bit open ended as I'm not sure it's possible or
Here is my html: <form> <dl> <dt>&nbsp;</dt> <dd><input type=hidden></dd> <dt>Dont hide this one</dt> <dd><input
I code this function which converts all pipes into commas, and after that converting
I have this code for adding selected items from one ListBox to another. How
I have this simple code but I can't figure for the life of me
After some find and replace refactoring I ended up with this gem: const class
I'm a LAMP guy and ended up working this small news module for an
This is a difficult and open-ended question I know, but I thought I'd throw
I ended up writing a quick little script for this in Python, but I

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.