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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:11:25+00:00 2026-05-16T16:11:25+00:00

I am from c# object oriented background and which to work similar priniciples in

  • 0

I am from c# object oriented background and which to work similar priniciples in javascript. Any good I articles that could help with me research?

This is an example i put together for a Product Javascript object:

function Product() {
    this.reset = function () {
        this.id = 0;
        this.name = '';
    }
}

Product.prototype = {
    loadFromJson: function (json) {
        this.reset();
        this.id = json.Id;
        this.name = json.Name;
    },

checkAvailability: function (qty) {
    // Just to illustrate
    return true;
}
};

So to create an instance of Product:

var p = new Product();

To access a public method:

var isAvailable = p.checkAvailability(1);

To access a public property:

var name = p.name;

Is the reset function I create a valid private function?

Is what I am doing above correct or is there a better way? I am new to this!

Also, if I create an instance of product in another javascript file, can I get intellisence on the properties of the Product object?

  • 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-16T16:11:26+00:00Added an answer on May 16, 2026 at 4:11 pm

    The reset is this.reset(); so that is in the scope of the object and thus could be called public, but remains in that scope. In your example p.reset(); but reset(); fails.

    Better way? It depends, some circumstances require this complex, some do not. There are a number of ways to instantiate objects (everything is an object in JavaScript) and your examples are some of the ways.

    No intellisence unless you build and attach your own (a LOT of work). (search on jQuery intellisence to see how that is done)

    See this for some more regarding namespace. Note the internal and public functions and variables.

    var myStuffApp = new function()
    {
        var internalFunction = function()
        {
            alert('soy una función interna');
        };
        this.publicFunction = function()
        {
            alert('soy una función pública');
        };
        var test1 = 'testing 1';//private/internal
        this.test2 = 'testing 2';// namespaced
        testA="ho";// global
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Question from Object-Oriented JavaScript book: Imagine Array() doesn't exist and the array literal notation
I would like to know if PHP is Object Oriented, I read that from
I'm comming from an scientific background and I'm having trouble to think object oriented.
I come from an Object Oriented background. Why does Test (notice the quotes) display
I am a Scala beginner and coming from Object Oriented Paradigm. While understanding Functional
I'm working on an object-oriented Excel add-in to retrieve information from our ERP system's
Hello I was trying to remove objects from object array that I have and
All of our reports are created from object graphs that are translated from our
I come from a Java/C++ OOP background and am trying to get into JavaScript
I'm currently going through Stoyan Stefanov's book Object-oriented JavaScript and I've stumbled on an

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.