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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:10:02+00:00 2026-06-16T10:10:02+00:00

i have this script: var Tord = (function () { Tord.prototype.getHeader = function ()

  • 0

i have this script:

var Tord = (function () {

    Tord.prototype.getHeader = function () {
        alert('test');
    };

    return Tord;
})();

$(document).ready(function() {

    var tod = new Tord();
    tod.getHeader();
});

i get an error Uncaught TypeError: Cannot read property 'prototype' of undefined line 3

i don’t understand why?

here is how my js files are loaded:

    <link rel="stylesheet" href="public/jquery.mobile/jquery.mobile-1.2.0.min.css" />
    <link rel="stylesheet" href="public/style.css" />
    <script src="public/jquery-1.8.3.min.js"></script>
    <script src="public/jquery.mobile/jquery.mobile-1.2.0.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="public/cordova-2.2.0.js"></script>
    <script type="text/javascript" charset="utf-8" src="public/script.js"></script>

script.js has the script from above.

any ideas? thanks.

  • 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-16T10:10:03+00:00Added an answer on June 16, 2026 at 10:10 am

    Because of exactly the code you’ve shown. Look, when this line is invoked…

    Tord.prototype.getHeader = function () {
    

    … Tord is undefined. But Tord should be a function when you set this (as prototype should be a property of constructor function to be of any use) – and you don’t make any efforts to make Tord a function at all.

    I think what you want to do may be achieved with this:

    var Tord = (function () {
        var Tord = function() {}; // to properly name the constructor
        Tord.prototype.getHeader = function () {
            alert('test');
        };
        return Tord;
    })();
    

    With this you can define different constructors based on some external logic (but still define them once). But in the current state of your code there’s no need to make it that complex: this…

    var Tord = function() {};
    Tord.prototype.getHeader = function() { ... };
    

    … should suffice, in my opinion.

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

Sidebar

Related Questions

Hi I have this script: function ajax(){ if (navigator.standalone) return; for (var i= document.links.length;
I have this tiny script: var $totalHeight; $(document).ready(function() { $totalHeight = $('#sidebar-container').innerHeight(); $('.sidebar-heading').each(function() {
I have this javascript code <Script> function getGroupId(){ var group=document.getElementById(selectedOptions).value; var groupFirstLetter=group.substring(2); } </Script>
I have this little script: var moolang = new Class({ initialize: function(element) { this.el
Lets say i have this javascript code in an html pages <script type=text/javascript> $(document).ready(function(){
I have a question regarding the php validation, I have this script $(document).ready(function(){ //
I have this script: function calculate(){ passworda = document.password1.user1.value.toLowerCase() passwordb = document.password1.pass1.value.toLowerCase() var user
I have this script using jquery: $(document).ready(function() { $('.fotky,.video,.diskusia,.onas,.zbrane,.akcie,.tabroz,.tabburk,.tabhil,.tablest').append('<span class=hover></span>').each(function () { var $span
so i have this script: <script type=text/javascript> $(window).load(function () { var imagePath = new
I have this script: #!/var/home/cherry/opt/perl use Test::More; use DBI; use Test::mysqld; use Data::Dumper; my

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.