How do constructors work without new keyword?

Hi guys,
I'm developing UI5 applicaitons.
I use jsview to build the UI.
In one of the pages, I need a dialog to popup.
So define a dialog in createContent funciton of the view:
        var dialog = new sap.m.Dialog(this.createId('idDlg'), {
            content: [
                new sap.m.Input()
            beginButton: new sap.m.Button({
                text: 'OK',
                press: [oController.onOKPressed, oController]
            endButton: new sap.m.Button({
                text: 'Cancel',
                press: [oController.onCancelPressed, oController]
But afterwards, I find there's no need to declare a variable to store the dialog instance, so I remove it, it still works:
        new sap.m.Dialog(this.createId('idDlg'), {
            content: [
                new sap.m.Input()
            beginButton: new sap.m.Button({
                text: 'OK',
                press: [oController.onOKPressed, oController]
            endButton: new sap.m.Button({
                text: 'Cancel',
                press: [oController.onCancelPressed, oController]
And after that, I'm using jslint to check code statically, lint tells me do not use new for side effects, so I remove the new keyword, it still works:
        sap.m.Dialog(this.createId('idDlg'), {
            content: [
                new sap.m.Input()
            beginButton: new sap.m.Button({
                text: 'OK',
                press: [oController.onOKPressed, oController]
            endButton: new sap.m.Button({
                text: 'Cancel',
                press: [oController.onCancelPressed, oController]
So I'm wondering why the constructor still works even without new?
what will the above code do?
And what's the difference between with and without new?
Regards,
Aaron.

Let me give you a simle example. say you've a constructor
var Constructor = function(name){
     this.name = name;
You create an instance of constructor as,
var oInstance = new Constructor("My Instance);
the Constructor will get executed with the context 'this' as 'oInstance'.
oInstance.name // My Instance
var oInstance = Constructor("My Instance);
the Constructor will get executed with the context 'this' as 'window'.
oInstance.name // Type Error
window.name // My Instance

Similar Messages

  • How to delete photos without a keyword

    I have 10,000+ photos from my son's football season in Events in iPhoto 09. I only want to keep the ones that I have marked with a specific keyword. This seems like it should be a simple task but I can't seem to figure out how to select photos without a keyword and then be able to delete them from my library. Can anyone help?

    make a smart album Keyword is not "your special key word" and delete the photos form that album
    LN

  • How jvm threads works on new Linux 2.6 scheduler with SMP kernell

    Hi,
    i'm using Sun JDK Java HotSpot(TM) Server VM (build 1.5.0_14-b03, mixed mode) to run tomcat,
    anyone knows How JVM threads works on new Linux 2.6 scheduler with SMP kernel?
    i ask this, because in a single processor machine the tomcat replies more fast than a dual processor machine, maybe the reason is, that SMP load balancing made for new scheduler, slow down the JVM performance for threads? there is a way to avoid this?
    reference about Linux Scheduler: http://www-128.ibm.com/developerworks/linux/library/l-scheduler/?ca=dgr-lnxw09LinuxScheduler
    bug that have "same" problem: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5038858
    thanks for any insight

    This is bug:
    6328462 Linux getCurrentThreadCpuTime() does not match with getThreadCpuTime(currentThread)
    It will be fixed in:
    - JDK 6.0 (Mustang) build b63
    - JDK 1.5.0_07 build b01
    The problem is that the HotSpot VM takes the stat info from the file'/proc/$tid/stat'
    which is incorrect on Linux kernels 2.6+ with NPTL because this file aggregates
    per-process (.vs. per-thread) usage on these kernels.
    The file '/proc/self/task/$tid/stat' still has the per-thread usage and must be used instead.
    There is also a performance bug:
    6200022: JVMTI GetCurrentThreadCpuTime slow on Linux
    This bug is about using new Linux posix compliant process clocks (2.6.10) :
    http://sources.redhat.com/ml/libc-alpha/2004-10/msg00117.html
    It is too late to fix this in Mustang but can be possible in one of the update releases.
    Thank you for posting the question!
    Serguei

  • How can I work without a keyboard on a touch based station in windows multipoint server?

    I am using Windows Multipoint Server 2012 Premium evaluation version. How can I work on a station, with integrated touch feature, without a keyboard?
    In the beginning itself the station is stuck at "Creating a multipoint server station. Press 'C'". Now, since I a want all interactions on this station to be touch based, I have not provided any keyboard to press 'C' there. How can I login and
    operate this station?
    Thanks in advance.

    No, an ipod can only sync with one computer at a time. You could buy the songs on both laptops using the same apple id, but you can only sync with one of the laptops.

  • How does gnome work without acpid?

    Hi,
    I have set up gnome3 with laptop-mode-tools, but without acpid on my laptop. The power-management stuff works, but seems incomplete. For example, gnome is able to detect when I remove the AC plug, or close the lid, or press the sleep button. But it does not seem to detect when power is critically low, and does not sleep/hibernate, like it's configured to do. There's also a problem I think to do this when laptop is already sleeping. I left it once over night in sleep mode, with little battery power remaining, to test it. The expectation was to resume from sleep when battery was critically low and go hibernate. Instead it just crashed.
    The wiki's suggest that acpid daemon is required to deliver acpi events, but then I wonder: how does gnome (and possibly also laptop-mode-tools) detect these events without acpid?
    Razvan

    Acpid just listens on acpi events but not creates them.
    You can always listen to acpi events using the command 'acpi_listen'
    Regards

  • HT4915 Since downloading the latest iTunes, I am unable to delete songs from my iPhone 4s and songs I have purchased on iTunes are not available on my iPhone 4s. My computer no longer seems to recognise my iPhone or iPad. How do I work the new iTunes plea

    I hate the new iTunes, I can't find anything and can't delete music from my iPhone4S. I can't find my iPhone or iPad when I plug them into my computer and I now have a whole lot of stuff I don't want on my phone. I have relaxation music on my iPad (for work) and other music on my iPhone. The new iTunes has now put everything on my iPhone and I can't get it off. I've disabled Match from my iPad to prevent the wrong music from appearing. Help please someone, I'm going insane.

    In iTunes go to View>Show Sidebar.  This will make it look and behave more like previous versions.  Then connect your phone, click on it's name on the left side, go to the Music tab and make sure you haven't selected Sync your entire library.  You may want to check the songs in your library that you want on your phone, then go to the Summary tab of your iTunes sync settings and select Sync only checked songs and videos, then click Apply at the bottom to sync your phone.  This should transfer only the checked songs and remove the rest.

  • How remote monitoring works -- without any agents at remote machine

    Using JAVA, Is there any way to execute a system level command on the remote machine and get back the data to the host machine.
    It should work something like this, my application resides on Windows, and it should send a system command to the remote machine (Solaris) like vmstat and getback the resultant output to my application. This should be achieved without installing any agents at the remote machines.
    Suggest me some good advice to design this application.

    Most Unix boxes run a Telnet serverActually, if the sysadmins are smart, there's no
    telnet server nor a telnet client in sight - they've
    been removed and sshd is running. Most (if I
    remember correctly) Linux distros now do not
    install telnetd by default, but sshd is. I use
    Linux/Solaris 100% of the time, at work and at home,
    and I can't even remember the last time I fired up
    "telnet."This is a good point and hints to the fact that any application must define and document
    its dependencies. In this case the application must document that the appropriate server daemon
    must be running for it to work, whether telnetd, rshd or sshd. No assumptions can be made about any
    of these daemons as they can all be turned off and not running.
    For this application to run the user must be able to turn on the required daemon at the required
    server. This is not the same but somewhat equivalent to requiring the installation of a
    specialized daemon at the server. In all cases the user must have administrative access to the server,
    either directly or indirectly.

  • How does FaceTime work without wifi now?

    I have tried to use FaceTime multiple times and it always told me that I needed wifi. I went to show my friend what it said when I tried it and it worked. Wifi free! *** why couldn't it work all the time like that

    As the following article states, FaceTime requires:
    An active Wi-Fi connection or cellular data connection. Additional account features may be required to use FaceTime over Cellular. Contact your carrier for more details.
    http://support.apple.com/kb/TS3367

  • How can i work without grid in sun creator

    Hello guys,
    how can i place component in sun creator anywhere i like instead of being restricted to place it within the grid (i.e placing component within the box drawn in sun creator (specific x and y axis))
    thanks
    Message was edited by:
    kaskalee

    Go to Tools|Options and select Visual Designer.
    Clear Snap to Grid checkbox. This should let you precisely place a component anywhere on the canvas.
    If you don't want the grid lines, clear the Show Grid checkbox.

  • How the listener working without listener.ora file?

    Hi alls,
    System env.
    Oracle : 8.1.6
    OS: Win2K
    There's no file listener.ora on the machine. But there's a TNSlistener service running. Is the listener can start with tnsnames.ora?
    Any idea?
    Witch.

    I'm surely that nobody delete that file.
    On the last Friday, I logon to the server and tried to use svrmgrl but I got an error like this
    "SVRMGR> connect sys@tcard;
    Password:
    ORA-12154: TNS:could not resolve service name".
    So I checked the listener by running this command
    "lsnrctl services"
    and I got this
    "Connecting to (ADDRESS=(PROTOCOL=ipc)(KEY=PNPKEY))
    TNS-12541: TNS:no listener
    TNS-12560: TNS:protocol adapter error
    TNS-00511: No listener
    32-bit Windows Error: 2: No such file or directory
    Connecting to (ADDRESS=(PROTOCOL=tcp)(PORT=1521))
    TNS-12545: Connect failed because target host or object does not exist
    TNS-12560: TNS:protocol adapter error
    TNS-00515: Connect failed because target host or object does not exist
    32-bit Windows Error: 49: Unknown error
    I tried to check the file "tnsnames.ora" but didn't find it.
    Any idea?
    Thanks,
    Witchuda.

  • HOW TO WORK THE NEW UPDATE

    HOW DO YOU WORK THE NEW iOS UPDATE FOR THE IPHONE 3G.

    What do you mean?
    Install it?
    How to update?
    Or what is new with it and how to use new features?
    If how to use new stuff, have to tell us what phone you have.

  • Toplink JPA LAZY loading in Java SE works without javaagent?

    hi there,
    I tought that mappings like
    @JoinColumn(name = "join_col_name")
    @ManyToOne(cascade=CascadeType.ALL, fetch=FetchType.LAZY)
    private RelatedObject relObj;
    with TopLink JPA in Java SE environment works ONLY with the
    -javaagent:toplink-essentials-agent.jar
    JVM parameter?
    the strange thing is: I did 2 test runs, with and without the java agent parameter. I also could see that in the first case the weaver is working, in the second the property "toplink.weaving=false" is printed to the console BUT if I access the LAZY mapped attribute of the object instance it works in both cases - I expected a NullPointerEx. in the case without the javaagent.
    Is there anything I missed?
    Hans

    Chris,
    thank for for the tip about verifying lazy or eager fetching. The results are interesting - or better: confusing - to me:
    I have built a test project with 3 entities:
    Entity A hast @OneToMany to Entity B and
    Entity B has ManyToONe to Entity C
    A <-- B --> C
    ALL relations are marked with FetchType.LAZY in all directions.
    When I simply run the test project via main()-method out of eclipse, WITHTOUT specifycing a -javaagent parameter in the run dialog, I can confirm using your test case that the realtion IS LAZILY FETCHED.
    So, I do not really know how this should work without the javaagent.
    You mentioned statically weaved classed - is this the default case when no agent is present, how is it done? Toplink logging says that weaving is NOT active:
    ServerSession(16821027)--Thread(Thread[main,5,main])--property=toplink.weaving; value=false
    so how can the lazy loading work then?
    regards,
    Hans

  • How can i work in office word or excel

    Hello sir,
    1) Is there any options to make new file in word or excel?
    2) How can i work in new file of word or excel or it's only use for update file?

    Davlem wrote:
    I work at the same tieme in two laguagues I mean in a pages document I work in English but in other one I am working in French. I can't be changing from English to spanish etc, that's really complicated because I have to be restarting the computer each time I am doing that
    In Pages you just go to Inspector > Text > More > Language and switch it there.  No need to restart anything.
    For other apps, you can try Edit > Spelling and Grammar > Show Spelling and Grammar and change the dictionary there.
    I don't think there is yet any reliable way to change spellcheck automatically when you change language.

  • How build applicatio​n without labview

    i build application in my PC. My Pc include professional LV but if  try my programe work  another PC without LV the programe not work
    so i need my programe worke in pc without LV
    can help me how my programe worke without LV
    Note: my programe main Vi and contain sub VI

    Create application to run in another PC with no labview installed:
    1 - create application
    2 - create installer that include the application
    If you run the installer in the other PC, It install the application and the labview runtime (necessary to run your application).
    If you want another solution, just download labviewruntime from NI and install in the PC with no labview.
    Software developer
    www.mcm-electronics.com
    PS: Don't forget to rate a good anwser ; )
    Currently using Labview 2011
    PORTUGAL

  • How to reference a class without using the new keyword

    I need to access some information from a class using the getter, but I don't want to use the new keyword because it will erase the information in the class. How can I reference the class without using the new keyword.
    ContactInfo c = new ContactInfo(); // problem is here because it erases the info in the class
    c.getFirstName();

    quedogf94 wrote:
    I need to access some information from a class using the getter, but I don't want to use the new keyword because it will erase the information in the class. How can I reference the class without using the new keyword.
    ContactInfo c = new ContactInfo(); // problem is here because it erases the info in the class
    c.getFirstName();No.
    Using new does not erase anything. There's nothing to erase. It's brand new. It creates a new instance, and whatever that constructor puts in there, is there. If you then change the contents of that instance, and you want to see them, you have to have maintained a reference to it somewhere, and access that instance's state through that reference.
    As already stated, you seem to be confused between class and instance, at the very least.
    Run this. Study the output carefully. Make sure you understand why you see what you do. Then, if you're still confused, try to rephrase your question in a way that makes some sense based on what you've observed.
    (And not that accessing a class (static) member through a reference, like foo1.getNumFoos() is syntactically legal, but is bad form, since it looks like you're accessing an instance (non-static) member. I do it here just for demonstration purposes.)
    public class Foo {
      private static int numFoos; // class variable
      private int x; // instance varaible
      public Foo(int x) {
        this.x = x;
        numFoos++;
      // class method
      public static int getNumFoos() {
        return numFoos;
      // instance method 
      public int getX() {
        return x;
      public static void main (String[] args) {
        System.out.println ("Foo.numFoos is " + Foo.getNumFoos ());
        System.out.println ();
        Foo foo1 = new Foo(42);
        System.out.println ("Foo.numFoos is " + Foo.getNumFoos ());
        System.out.println ("foo1.numFoos is " + foo1.getNumFoos ());
        System.out.println ("foo1.x is " + foo1.getX ());
        System.out.println ();
        Foo foo2 = new Foo(666);
        System.out.println ("Foo.numFoos is " + Foo.getNumFoos ());
        System.out.println ("foo1.numFoos is " + foo1.getNumFoos ());
        System.out.println ("foo1.x is " + foo1.getX ());
        System.out.println ("foo2.numFoos is " + foo2.getNumFoos ());
        System.out.println ("foo2.x is " + foo2.getX ());
        System.out.println ();
    }

Maybe you are looking for

  • Mini-DVI to VGA frustrations

    I have a mini dvi to vga adapter connecting a CRT to my macbook, everything was working great untill... it turned pink, everything on the display has a really bad pink tint, ive tryed it with different displays... no luck... So I call apple care to s

  • E1200 V2 upgraded to OS 10.8.2, Cisco Connect unsupported OS, also update firmware?

    I purchased myu E1200 Jan 2012. Have been intermittent loss of connection & not sure whether it is old cable modem or router or? ISP came out & checked & changed some cable fittings said looked ok, but could be my old modem. (I'm getting ready to mov

  • Sales calculation

    Hello, I need to calculate monthly sales of my company. As for now i have used the following condition in VBRK table. Total sales invoices generated per month (excluding canceled invoices)  - Total return invoices generated per month. I pass these in

  • How do I stop or block caches?

    I am now on Mountanin Lion. I have been able to block cookies by using the Safari preferences to do this.  However I still get hundreds of "Caches" from God only knows what websites that still appear in Safari until I remove them. I don't trust cache

  • V4 - Display the Version in the Banner

    Currently the top banner shows something like "Oracle SQL Developer - Databases.jws : IdeConnections%23DEV.jpr in V3 => Oracle SQL Developer : DEV DEV being my Connection Name I am sure there is a good reason for the jws and jpr information not that