Is there a difference between a function with and without a return statement?

后端 未结 3 1051
小鲜肉
小鲜肉 2021-01-18 12:41

Say you have 2 identical functions that do not return a value

function a() {
    // do some interesting things
}

function b() {
    // do the same interesti         


        
3条回答
  •  一整个雨季
    2021-01-18 12:58

    Generally you are returning a value. So for instance,

    function b() {
      return 'hello';
    }
    
    a = b();
    
    console.log(a);
    

    Will output "hello" to your console.

提交回复
热议问题