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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:39:04+00:00 2026-05-16T20:39:04+00:00

I am new to JavaScript OO programming please bear with me for any ambiguities.

  • 0

I am new to JavaScript OO programming please bear with me for any ambiguities.

I have a method that requires an object as its arguments.
The required object sets options for the method to work with.

var objInstance = csvObj.getData({
    url: '', // csv url

    format: '', // return data format

    onComplete: function (output) {
           // a function that will display data returned
    }
});

csvObj is defined below

var csvObj = { 
    getData: function (o) {

        var format = o.format || 'json',  //optional options 
            url = o.url, callback = o.onComplete;   // required options

        function include_js(jsurl) {  // private function for performing cross dormain requests
            var script = document.createElement("script");
            script.type = "text/javascript";

            script.src = jsurl;
            document.getElementsByTagName("head")[0].appendChild(script);
        }


        (function () { // anonymous function for proccessing and returning data

            if (typeof  callback === 'function' && url) {  // if require options are defined

                if (!window.call_back) {    // and global call_back function is not yet defined
                    window.call_back = callback;  // define global call_back function (will be called when external script is loaded)
                }

                var restQuery = 'http://query.yahooapis.com/v1/public/yql?q=',
                query = 'select * from csv where url="' +  url + '" and columns="' + cols + '"', 

                yqlQuery = restQuery + encodeURIComponent(query)  + '&format=' + data + '&callback=call_back'; // create YQL query
                include_js(yqlQuery);  // create a cross dormain YQL request 
            } 
        else {
               alert('onComplete function or csv url not defined.'); // required options not defined
            }
        }());  

    }
};

Question: Is there a better way of handling object arguments than simply accessing like this:

var privateProperty = object.property; or

var privateMethod = object.method;
  • 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-16T20:39:04+00:00Added an answer on May 16, 2026 at 8:39 pm

    Your approach is totally valid. You could do it like this, too:

    var privateMethod = object['method'];
    

    This can be very handy for dynamically getting properties, but in general i prefer object.method, because it is much easier to read.

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

Sidebar

Related Questions

Please bear with me as I am new to dojo, javascript, and web programming
I am completely new to javascript programming and I have a question that I
I am new to Javascript and object-oriented programming in general. I would like to
I'm somewhat new to object oriented programming in Javascript and I'm trying to build
I am very new to jQuery and javascript programming. I have a program below
I'm relatively new to web programming. New to Javascript, PHP, Ajax, etc. I have
Have been following this fabulous tutorial . Being new to Javascript and functional programming,
I'm new to web programming and I have the following form that I wish
I'm quite new to javascript programming and got stuck in this problem: I have
I`m a JavaScript/programming newbie trying to figure out the new bookmarklet that's been released

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.