javascript - variable(search) not defined error -


function sort(type) {     $("#parentdiv").empty();     $.getjson("raw_data.json", ({ search }));      function sear(a, b) {         return (a[search.type] < b[search.type]) ? -1 : (a[search.type] > b[search.type]) ? 1 : 0;     }; } 

my raw_data.json here.

though i've declared search. occuring error:

search not defined.

function sort(type) {   $("#parentdiv").empty(); $.getjson("raw_data.json", ({ search }) => {        search.sort(function(a,b){     if(a[type]<b[type]){return -1;}      else if(a[type]>b[type]){     return 1;     }     else {     return 0;     }     });     console.log(`sorted by: ${type}`);     console.log("movies displayed!!");     var i;    ... code 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo