Adding Subclass to Main Class in JavaScript

var Test = { Hoi : { test: function(e) { console.log(e); } }, c: function(e) { console.log(e); } }; Test.c("hey 1"); Test.Hoi.c("hey 2");

I've doing some classes exercising, but I can't find manage to put subclasses into a main class.

-------------Problems Reply------------

Test.Hoi.c doesn't exist; Test.Hoi.test does use:

Test.Hoi.test("hey 2");

each dot basically digs a step deeper into the structure of the object.

You must create the c method.

Hoi : {
test: function(e) {
c: function(e) {
Test.Hoi.c("hey 2");

Category:javascript Views:4 Time:2018-06-08

Related post

  • adding functions to main class from a different class using bean configuration if possible 2011-07-04

    Well I hope I'll be clear enough about what I want to achieve. I apologize if I can't quite explain myself properly or if I'm talking nonsense, please bare with me :) I'm writing a red5 application in Java. it just means that I have a bean that point

  • What are the perfomance repercussions of adding functions to the String class in JavaScript and Node.js? 2011-06-27

    What are the repercussions of adding functions to the String class in JavaScript? Is this a bad idea? E.g., // String functions String.prototype.startsWith = function(string) { return (this.indexOf(string) === 0); } String.prototype.empty = function(

  • Adding a new font to FOP. couldn't find main class. program will now exit 2011-05-30

    I am trying to add a new Font to FOP. I start creating a metric font file by running this: java org.apache.fop.fonts.apps.TTFReader C:\WINNT\Fonts\msgothic.ttf msgothic.xml But I keep getting the same error: Could not find the main class: org.apache.

  • adding main class into the manifest file 2011-07-05

    I created a jar file like this : jar cf myJAR.jar *.class But this thing is not executable because the mainfest file does not know in which .class file is the main file ? Now how can i set the main class into the manifest file ? --------------Solutio

  • What's the best way to define a class in JavaScript? 2008-12-22

    I prefer to use OOP in large scale projects like the one I'm working on right now. I need to create several classes in JavaScript but, if I'm not mistaken, there are at least a couple of ways to go about doing that. What would be the syntax and why w

  • Can't access the main class from another class 2010-11-05

    I m working with NetBeans, and I m trying to program a program that has a user interface. My main class is a JFrame form and its file name is I can write all the code in this file without any problem, but the code will be too complex an

  • Select subclass from base class-possible? 2010-11-21

    I am learning C++ and I am stuck with a problem. I need a way to use a specific subclass within base class. Does it make sense or I am using a wrong approach? SelectBrand should select the subclass, how can I do it? Here below my simplified classes:

  • Python-Like "Classes" in Javascript 2011-08-21

    I was wondering how one would go about making "classes" similar to those in Python in Javascript. Take the Python classes and functions listed here: class one: def foo(bar): # some code The function "foo" would be called with What would

  • "Could not find the main class. Program will exit" 2008-09-23

    I'm trying to run SQuirreL SQL. I've downloaded it and installed it, but when I try to run it I get this error message: Java Virtual Machine Launcher. Could not find the main class. Program will exit. I get the gist of this, but I have not idea how t

  • Change an element's CSS class with JavaScript 2008-10-12

    How can I change a CSS class of an HTML element in response to an onClick event using JavaScript? --------------Solutions------------- Adding and Removing Classes, with simple cross-browser JavaScript The standard JavaScript way to select an element

  • Is there a pattern for adding "options" to a class? 2008-10-18

    I have a class on which I want to allow several (~20+) configuration options. Each option turns on or off a piece of functionality, or otherwise alters operations. To facilitate this, I coded a separate options class with default values. However, I h

  • How do I create an abstract base class in JavaScript? 2009-02-28

    Is it possible to simulate abstract base class in JavaScript? What is the most elegant way to do it? Say, I want to do something like: - var cat = new Animal('cat'); var dog = new Animal('dog'); cat.say(); dog.say(); It should output: 'bark', 'meow'

  • Imported Java applet project into netbeans won't work, Netbeans refuses to identify or even find main class even when manually set 2009-03-20

    I'm trying to set the main class in netbeans to be the main class it was in the last environment it was in, however the program insists it can't find the main class itself and when I set it as the name of the main class in project properties it says

  • What is this C++ technique for adding types to a class called? 2009-10-29

    I've just found some C++ code (at, which uses a technique I've never seen before to add types to an existing class: class Testpm { public: void m_func1() { cout << "m_func1\n"; }

  • Passing LoaderInfo to "Main" class from Preloader? 2009-11-13

    I initially wrote my Main class to read from LoaderInfo to parse some parameters, but then I recently added a Preloader, with that being the "main class". Is there a clean way to move things over, or to retrieve LoaderInfo? --------------Solutions---

  • difference between these 2 ways of creating a class in javascript 2010-01-31

    what are the difference between these two ways of creating a class: var apple = { type: "macintosh", color: "red", getInfo: function () { return this.color + ' ' + this.type + ' apple'; } } function Apple (type) { this.type = type; this.color = "red"

  • WSDL2Java Throws Could not find main class: org.apache.axis.wsdl.WSDL2Java 2010-02-19

    I am trying to create the java files from a remote webservice. I downloaded axis 1.4, copied the lib folder to c:\data\axis\lib which contains of these files: axis.jar axis-ant.jar commons-discovery-0.2.jar commons-logging-1.0.4.jar jaxrpc.jar log4j.

  • How to resolve main class not found exception while creating jar? 2010-03-03

    I am creating an executable jar file of a java project. I successfully created a sample jar file with Hello world class. I used following commands to create a jar: trail> javac -classpath "c:\Program Files\Java\jdk1.6.0_01\bin;" bin

  • Why has it failed to load main-class manifest attribute from a JAR file? 2010-04-07

    I have created a JAR file in this way jar cf jar-file input-files. Now I try to run it. This does not work (jre command is not found): jre -cp app.jar MainClass This does not work either: java -jar main.jar (Failed to load Main-Class manifest attribu

  • How to use addchild in another class not the main class as of .fla file? 2010-06-03

    i want to add to stage a movieclip in another class not the .as file as the same name of .fla file how can i get this. When i run same code in i get the result but in another class it runs but no result. --------------Solutions------------- F

  • Cannot find Main Class in File Compiled With Ant 2010-06-29

    I compile and run my program in Eclipse and everything works fine, but when I package it with Ant and run it, I get this error: Exception in thread "main" java.lang.NoClassDefFoundError: org/supercsv/io/ICsvB eanReader Caused by: java.lang.ClassNotFo

  • Implementing class descriptors by subclassing the `type` class 2010-07-18

    I'd like to have some data descriptors as part of a class. Meaning that I'd like class attributes to actually be properties, whose access is handled by class methods. It seems that Python doesn't directly support this, but that it can be implemented

  • How to inherit a C++ class in JavaScript? 2010-07-18

    I am embedding SpiderMonkey to make my C++ library scriptable. To make it extendable, I need it possible to define a new class (JavaScript) inheriting one C++ base class of the library. Is there an example showing me how to do that using SpiderMonkey

  • AS 3.0: Calling a method, which is defined in another class, from Main class gives Error 1120 2010-08-16

    I have two classes. The Main class calls a function, which is defined in a Second class. I'm getting the following error: Error 1120: Access of undefined property myFunction Basically, I am creating buttons in the Main class that will add a correspon

Copyright (C), All Rights Reserved.

processed in 0.162 (s). 11 q(s)