<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>第一个javascript计算页面</title></head><body> <script type="text/javascript"> function sum(a,b) { if((typeof a)== "number" && (typeof b)== "number"){ return a+b; } alert("您输入的数据不合法"); }var v1=sum(); alert(v1); var v2=sum(10); alert(v2); var v3=sum(10,20); alert(v3); var v4=sum(false,"sun"); alert(v4);</script></html>
原文地址:https://www.cnblogs.com/god1/p/12114206.html
时间: 2024-10-13 12:58:02