« Return to Thread: NetBeans Ruby JavaScript Support

NetBeans Ruby JavaScript Support

by bruparel :: Rate this Message:

Reply to Author | View in Thread

I just started playing with JavaScript using NetBeans.  I must say I am impressed!  Really good support for HTML/CSS/Javascript editing.

One thing that puzzles me about the NetBeans JavaScript editor is its insistence on saying "Anonymous function does not always return a value..." even when the function really does.  The following JavaScript function is from the second Chapter of JQuery in Action book:

$.toSource = function(target) {
   if (typeof target.toSource !== 'undefined' && typeof target.callee === 'undefined') {
      return target.toSource().slice(1,-1);
   }
   switch (typeof target) {
      case 'number':
      case 'boolean':
      case 'function':
         return target;
         break;
      case 'string':
         return '\'' + target + '\'';
         break;
      case 'object':
         var result;
         if (target instanceof Date) {
            result = 'new Date('+target.getTime()+')';
         }
         else if (target.constructor === Array || typeof target.callee !== 'undefined') {
            result = '[';
            var i, length = target.length;
            for (i = 0; i < length-1; i++) { result += $.toSource(target[i]) + ','; }
            result += $.toSource(target[i]) + ']';
         }
         else {
            result = '{';
            var key;
            for (key in target) { result += key + ':' + $.toSource(target[key]) + ','; }
            result = result.replace(/\,$/, '') + '}';
         }
         return result;
         break;
      default:
         return '?unsupported-type?';
         break;
   }
}

You can see that every return statement returns a value.  Why is NetBeans popping up Hints?

Bharat

 « Return to Thread: NetBeans Ruby JavaScript Support

LightInTheBox - Buy quality products at wholesale price