Use RegExp, In case if any other options do not work for you, RegExp is a good option. It makes the string case sensitiveinsensitive.
var username = new RegExp("^" + "John" + "$", "i");;;
The value of username will be like /John/i.
use username in queries, and then its done.
I hope it will work for you too. All the Best.