examples/search/public/client.js JAVASCRIPT 16 lines View on github.com → Search inside
1'use strict'23var search = document.querySelector('[type=search]');4var code = document.querySelector('pre');56search.addEventListener('keyup', function(){7  var xhr = new XMLHttpRequest;8  xhr.open('GET', '/search/' + search.value, true);9  xhr.onreadystatechange = function(){10    if (xhr.readyState === 4) {11      code.textContent = xhr.responseText;12    }13  };14  xhr.send();15}, false);

Code quality findings 5

Remove event listeners when no longer needed to prevent memory leaks
warning performance event-listener-leak
search.addEventListener('keyup', function(){
Use let or const to avoid scope issues and hoisting
info correctness var-declaration
var search = document.querySelector('[type=search]');
Use let or const to avoid scope issues and hoisting
info correctness var-declaration
var code = document.querySelector('pre');
Use let or const to avoid scope issues and hoisting
info correctness var-declaration
var xhr = new XMLHttpRequest;
Use strict equality (===) to prevent type coercion bugs
info correctness loose-equality
if (xhr.readyState === 4) {

Get this view in your editor

Same data, no extra tab — call code_get_file + code_get_findings over MCP from Claude/Cursor/Copilot.