function Caller() { this.makeCall = function () { /*come code here*/ } this.init = function () { this.makeCall(); }; } var a = new Caller(); a.init();
var Caller=(function () { function constructor() { } function makeCall() { /*come code here*/ } constructor.prototype.init=function () { makeCall.apply(this, arguments); }; return constructor; })(); var a=new Caller(); a.init();
// do some setup in your constructor function Caller(phoneNumber) { this.phoneNumber = phoneNumber; }; Caller.prototype.init = function () { // the code word "this" will be the instance itself this.makeCall(); }; Caller.prototype.makeCall = function () { // do whatever this method needs to do alert('calling ' + this.phoneNumber); }; var a = new Caller(0123456789); a.init();
<html> <head> </head> <body> <script> function Caller() { this.init = function() { this.makeCall(); }; this.makeCall = function(){ alert('hello'); } } var a = new Caller(); a.init(); </script> </body> </html>
callIfNotNull(new Getter() { @Override public Object get() { return getterMethod(); } }, new Caller() { @Override public void call() { setter(); } }, new Object[]{null, '0'}); }
public static Caller createCaller(final SecurityIdentity securityIdentity) { checkPermission(ControllerPermission.CREATE_CALLER); return new Caller(securityIdentity); }
public TestClass() { CustomEvent bla = new CustomEvent("name", null, null); // TODO: parameterise mEventOnLoad = new TestEvent("onLoad", this, bla.new Caller() { @Override public void call(Object parent, Object callback, Object... objects) { // some code here } }); }
public static Caller createCaller(final Subject subject) { checkPermission(CREATE_CALLER_PERMISSION); return new Caller(subject); }
public static Caller createCaller(final SecurityIdentity securityIdentity) { checkPermission(ControllerPermission.CREATE_CALLER); return new Caller(securityIdentity); }
boolean save(){ Caller caller = new Caller(); caller = setCommonProperties(caller); caller.setCallerPropertyA(...); caller.setCallerPropertyB(...); ... //save caller return true or false; }