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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:56:50+00:00 2026-06-08T19:56:50+00:00

Possible Duplicate: How to “properly” create a custom object in JavaScript? Is it possible

  • 0

Possible Duplicate:
How to “properly” create a custom object in JavaScript?

Is it possible to construct new types in Javascript? If “everything is an object”, then are object constructors what you use for constructing new types? If so, this makes object constructors also type constructors, right? The help is very much appreciated, and good morning Stack Overflow!

  • 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-08T19:56:53+00:00Added an answer on June 8, 2026 at 7:56 pm

    You can use following code to create new Class and add methods and properties to that.

    function ClassName() {
    
       //Private Properties
       var var1, var2;
    
       //Public Properties
       this.public_property = "Var1";
    
       //Private Method
       var method1 = function() {
          //Code
       };
    
       //Privileged Method. This can access var1, var2 and also public_property.
       this.public_method1 = function() {
          //Code
       };
    }
    
    //Public Property using "prototype"
    ClassName.prototype.public_property2 = "Value 2";
    
    //Public Method using "prototype"
    //This can access this.public_property and public_property2. 
    //But not var1 and var2.
    ClassName.prototype.public_method2 = function() {
       //code here
    }
    
    //Create new Objects
    var obj1 = new ClassName();
    //Access properties
    obj1.public_property1 = "Value1";
    
    

    You can also extend exiting Classes.

    Check on Crockford’s website

    Thanks to Glutamat and Felix Kling

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

Sidebar

Related Questions

Possible Duplicate: How to “properly” create a custom object in JavaScript? Sorry if this
Possible Duplicate: Creating an “object” of an interface I am new to Java. Based
Possible Duplicate: “On file dialog cancel” event in JavaScript Is there a listener for
Possible Duplicate: “Least Astonishment” in Python: The Mutable Default Argument I'm trying to create
Possible Duplicate: What does “(void) new” mean in C++? I'm not familiar with C++
Possible Duplicate: What does “options = options || {}” mean in Javascript? I stumbled
Possible Duplicate: “long int”, “long long” Data Types I am a newbie of C++
Possible Duplicate: “new” keyword in Scala Ive noticed that creating certain instances in Scala
Possible Duplicate: Why write <script type=“text/javascript”> when the mime type is set by the
Possible Duplicate: What does “options = options || {}” mean in Javascript? Looking at

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.