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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:04:41+00:00 2026-06-04T12:04:41+00:00

I have following Html file with javascript. This gives me error that testCircle is

  • 0

I have following Html file with javascript. This gives me error that “testCircle is undefined.” kinldy help me resolve this.

<html>
    <body>
    <h1> Testing Object-based Javascipt </h1>
    <script type="text/javascript">
    function mycircle(x,y,r)
    {
    this.xcoord=x;
    this.ycoord=y;
    this.radius=r;
    this.area = getArea;
    this.getCircumference = function () { return (2 * Math.PI * this.radius ) ; };
    }
   function getArea()
   {
   return (Math.PI * this.radius * this.radius);
   }
        var testCircle = mycircle(3,4,5);

   window.alert('The radius of my circle is ' + testCircle.radius);

   </script>

   </body>
   </html>

Thanks in advance….

  • 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-04T12:04:43+00:00Added an answer on June 4, 2026 at 12:04 pm
    var testCircle = mycircle(3, 4, 5);
    

    should be

    var testCircle = new mycircle(3, 4, 5);
    

    Constructors are to be called with the new keyword. If the keyword is not used, you’re assigning the return value of the mycircle function. And as mycircle contains no return statement, the return values is undefined – that’s what you assigned to testCircle in your code.

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

Sidebar

Related Questions

I have a single .html file that looks similar to the following: <div id=myPage
I have a following problem, I have HTML form that uploads a file with
I have placed following javascript in my html file. <script TYPE=text/javascript> function srk(){ document.ontouchmove
I have the following file file: <html> <head> <title></title> <script type=text/javascript src=/Prototype.js></script> <script type=text/javascript>
I'm using this tooltip: http://flowplayer.org/tools/demos/tooltip/index.html I have the following lines in my html file:
I have the following code in an external JavaScript file that is called within
I have the following demo HTML file that I am tying to use the
In an HTML file I have the following: <input type=... name=myInput1 /> In a
I have the following in a html.erb file: <%= @location_list = [['test',2]] %> <script
I have the following code which loads and html file into a webview -

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.