Javascript - cannot statically reference non-static functions

I am making a reference to the javascript splice () function to an array and I am getting the error:

"Cannot make static reference to non-static splice () functions"

What's going on - how is it a static reference, I am not referencing an instance of the Array class and its method - how is it static?

$(document).ready( function() {

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

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

      

+2


a source to share


2 answers


This is not a Javascript engine post. It looks like you are using an IDE that provides syntax checking and the like. If you are using Eclipse, you may have encountered this error , which has been fixed quite recently.



+6


a source


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



  • Can be useful shorthand $(function() { });

    for document ready and []

    for array literal
  • arrayName is undefined in this function, is it defined elsewhere?
  • You need to close the argument list you are sending to $(document).ready()

    with a closing parenthesis)

  • Your padding is getting confused
  • The operator if

    will run immediately below it the line
+3


a source







All Articles