时间:2020-11-17 00:44:39 | 栏目:JavaScript代码 | 点击:次
return返回多个值,通过对象的属性访问
<!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>