开发者

Javascript - cannot make static reference to non-static function

I am making a reference to the Javascript function splice() on an array and I get the error:

"Cannot make a static reference to the non-static function splice()"

What's going on - how is this a static reference, aren't I referencing an instance of an Array class and its method - how is that static?

$(document).ready( function() {

var queryPreds = new Array();
var queryObjs = new Array();    

function remFromQuery(predicate) {
    for(var i=0; i<开发者_StackOverflow社区;arrayName.length;i++ ) { 
        if(queryPreds[i]==predicate)
        queryPreds.splice(i,1);
        queryObjs.splice(i,1);
        }
    }
}


That's not a Javascript engine message. It sounds like you're using an IDE that provides syntax checking and such. If you're using Eclipse, perhaps you're running into this bug, which has been fairly recently fixed.


Sorry, I don't have a direct answer, but I can offer these notes...

  • Could benefit from shorthand $(function() { }); for document ready and [] for array literal
  • arrayName in that function is not defined, is it defined elsewhere?
  • You need to close your argument list you send to $(document).ready() with a closing parenthesis )
  • Your indentation is confusing
  • That if statement will only run the line immediately under it
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜