サインを返します.
Math.sin(x)
sinメソッドはxのサインを-1から1までの範囲で返します.
以下にsinメソッドを使用したサンプルコードを示します.
<html>
<head>
<title>sinメソッドのサンプルコード</title>
</head>
<body>
<script type="text/javascript" language="javascript">
document.write(Math.sin(0) + "<br />");
document.write(Math.sin(Math.PI / 2) + "<br />");
document.write(Math.sin(Math.PI) + "<br />");
document.write(Math.sin(3 / 2 * Math.PI) + "<br />");
document.write(Math.sin(2 * Math.PI));
</script>
</body>
</html>
サンプルコードの実行結果は以下のようになります.
0 1 1.2246467991473532e-16 -1 -2.4492935982947064e-16
スポンサード リンク