Possible bug in JavaScript editor

Discuss all problems you have with Servoy here. It might help to mention the Servoy version and Operating System version you are using

Possible bug in JavaScript editor

Postby sergei.sheinin » Tue Aug 26, 2014 4:42 pm

I get a warning stating "The method join() is undefined for object []" for "join()" function in code below:

Code: Select all
function isThisABug(){
   
   var test = {element: []},
      str = '';
   
   test.element[0] = ['Apple', 'Orange', 'Banana'];
   
   str = test.element[0].join(',');
   
   
   
   application.output(str);
   
}


However the code runs as expected. This looks like a bug and I wasn't able to find a workaround yet (although I solved the problem by re-working the algorithm in the program).

Attaching a screenshot as well.
Attachments
eclipse_bug.png
eclipse_bug.png (9.6 KiB) Viewed 3784 times
Sergei Sheinin
JavaScript, RDBMS
http://js2dx.com
sergei.sheinin
 
Posts: 79
Joined: Wed May 07, 2014 3:22 pm

Re: Possible bug in JavaScript editor

Postby sovanm » Tue Aug 26, 2014 5:31 pm

Hi,

Adding JSDoc above your variable list will make servoy understand what kind of variable the objects contains.

Code: Select all
   /**@type {{element: Array<Array<String>>}}*/
      var test = {element: []},
            /** @type {String} */
            str,
            /**@type {String}*/
         str2;
      
      test.element[0] = ['Apple', 'Orange', 'Banana'];
      test.element[1] = ['Hello', 'world', 'Banana'];
      
      str = test.element[1].join(',');
      str2 = test.element[0].join(',');
      
      application.output(str);
      application.output(str2);


Here you would not get any warnings and also able to get the code completion for Array.

Output:

Code: Select all
Hello,world,Banana
Apple,Orange,Banana


Hope this will help you.

Thanks,
sovanm
 
Posts: 99
Joined: Fri Oct 28, 2011 1:55 pm
Location: Bhubaneswar, India

Re: Possible bug in JavaScript editor

Postby sergei.sheinin » Tue Aug 26, 2014 6:18 pm

Ic, thanks.
Sergei Sheinin
JavaScript, RDBMS
http://js2dx.com
sergei.sheinin
 
Posts: 79
Joined: Wed May 07, 2014 3:22 pm

Re: Possible bug in JavaScript editor

Postby Joas » Mon Oct 20, 2014 11:53 am

For more info, read this page on our wiki: Annotating JavaScript Using JSDoc.
Joas de Haan
Yield Software Development
Need help on your project? yieldsd.com
User avatar
Joas
Site Admin
 
Posts: 842
Joined: Mon Mar 20, 2006 4:07 pm
Location: Leusden, NL

Re: Possible bug in JavaScript editor

Postby jcompagner » Thu Oct 23, 2014 11:24 am

in this case even this was already fixing it:

Code: Select all
     var tst = {element: [[]]},
     str = '';
     tst.element[0] = ['Apple', 'Orange', 'Banana'];
     str = tst.element[0].join(',');
     application.output(str);


so just init the element directly as an array of arrays..
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet


Return to Discuss possible Issues and Bugs

Who is online

Users browsing this forum: No registered users and 7 guests