js return Returns multiple values accessing methods through the object's properties

  • 2021-07-22 08:46:18
  • OfStack

return returns multiple values, accessed through the object's properties


<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style></style>
  <script>  
  function add(a,b){
    var sum;
    var sub
    return{
      sum:a+b,
      sub:a-b
    }
  }
  var obj = add(5,2);
  console.log(obj.sum);
  console.log(obj.sub);

  </script>
</head>
<body>

</body>
</html> 

Related articles: