Javascript syntax function issue -


why following code work shouldn't title set lowercase causing second if statement fail?

var title = 'random_letters'; if(title.tolowercase() == 'random_letters') {      //this fire }  if(title == 'random_letters') {       //this still fire variable not saved lowercase } 

you aren't changing value of variable. can prove printing out value of variable @ each step.

var title = 'random_letters';  console.log(title); // here, title "random_letters"  if(title.tolowercase() == 'random_letters') {     console.log(title);     // here, title still "random_letters" }  console.log(title); // here, title "random_letters"  if(title == 'random_letters') {     //we line, our title still "random_letters" } 

according docs (https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/string/tolowercase), value of string using method not affected.


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -