javascript - Why does this loop produce undefined? -


why there 11th iteration, , why 'undefined' printed during it?

var num = 10; var start = 0; function x(){     while (start <= num){         console.log(start + '<br>');         start++;     } } console.log(x()); 

because x() not return when console.log() it.

var num = 10;  var start = 0;  function x(){      while (start <= num){          console.log(start);          start++;      }  }  x();

if return in function output return.

var num = 10;  var start = 0;  function x(){      while (start <= num){          console.log(start);          start++;      }    return 'end';  }  console.log(x());

now function returns 'end'.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -