JS——绝对值

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script>
    /* function abs(x) {
        if (x > 0) {
            return x;
        } else {
            return -x;
        }
    }
    alert(abs(-3)); */
    alert(Math.abs(-3));
</script>
</head>
<body>

</body>
</html>

 

posted @ 2016-03-26 16:39  绯乐  阅读(266)  评论(0编辑  收藏  举报