0
function test(){
}

test.prototype.doSomething = function () {  
return true;
}

in this example I can access test.doSomething(); But it whould be cool to just type t.doSomething(); Is it possible to define something like an alias for my class test?

2 Answers 2

1

Reference it in another variable. test will still exist. It's just that the variable t refers to it.

var t = test;
test.doSomething(); //test does something
t.doSomething();    //t does the same thing
Sign up to request clarification or add additional context in comments.

Comments

0

@Joseph's answer is spot on, but it's also worth nothing that your test function could be invoked as a Constructor via the new keyword:

var t = new test();
t.doSomething();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.