20.12.08-12日
🐱🐉Date
Dateオブジェクト
例>千分の一秒単位
例>1000ミリ秒=1秒
var **d** = **new** ** Date();**
document.getElementById("demo").innerHTML = d;
결과: Tue Dec 08 2020 10:15:00 GMT+0900 (대한민국 표준시)
New:メモリ作成ハイフンDate():ジェネレータメソッド
d:Dateオブジェクト
var d = new Date(); : 現在のコンピュータの日付と時刻情報を取得できます
🥶Creating Date Object
new Date()
new Date(year, month, day, hours, minutes, seconds, milliseconds)
new Date(milliseconds)
new Date(date string)
👉new Date()現在の日付と時刻を使用して、新しい日付オブジェクトを作成します.
👉new Date(year, month,...)
指定した日付と時刻を使用して、新しい日付オブジェクトを作成します.
var d = new Date(2018, 11, 24, 10, 33, 30, 0);
(7つの数字は年、月、日、時、分、秒、ミリ秒を指定します)JavaScriptは0から11までの月を計算します.
1月は0、12月は11です.
🥶Previous Century
1桁と2桁の年は19 xxと解釈されます.
var d = new Date(99, 11, 24);
🥶new Date(date String)日付文字列に新しい日付オブジェクトを作成します.
🥶new Date(milliseconds)
新しい日付オブジェクトを作成し、0時間以内にミリ秒を追加します.
1日(24時間)は86400000ミリ秒です.
ex)
var d = new Date(100000000000);
//1970년 1월 1일 +100,000000000 밀리 초는 대략 1973년 3월 3일이다.
🐱🐉Date Get Methods
読み出し値JS-Date Get Methods~
🐱🐉Date Set Methods
変更値JS-Date Set Methods
🐱🐉Math
JS-Marth例
🥶Math.round(x)
最も近い整数に四捨五入されたx値を返します.
🥶Math.ceil(x)
リフト関数(無条件四捨五入)
🥶Math.floor(x)
降下関数(無条件降下)
🥶Math.pow(x, y)
xの値はyの繰返し二乗を返す
🥶Math.sqrt(x)
xの平方根を返す
🥶Math.abs(x)
xの絶対値(正の値)を返します.
🥶Math.min()とMath.max()
引数のリストで、最も低い値または最も高い値を見つけることができます.
🥶Math.random()
0(含む)と1(含まない)の間の任意の数値を返します.
🐱🐉Booleans
👉2つの値の1つはtrueまたはfalseです.
true:0以外の値.存在値
ex)100
3.14
-15
"Hello"
"false"
7 + 1 + 3.14
false:0、「空白」...白物
document.getElementById("demo").innerHTML = Boolean(10 > 9);
결과: true
var x = 0;
document.getElementById("demo").innerHTML = Boolean(x);
결과: false
🐱🐉Comparisons
🥶AND演算子(&)
falseがfalseならfalse
var x = 6;
var y = 3;
document.getElementById("demo").innerHTML =
(x < 10 && y > 1) + "<br>" +
(x < 10 && y < 1);
결과:
true
false
🥶OR演算子(|)一つだけでも本当なら本当だ.
var x = 6;
var y = 3;
document.getElementById("demo").innerHTML =
(x == 5 || y == 5) + "<br>" +
(x == 6 || y == 0) + "<br>" +
(x == 0 || y == 3) + "<br>" +
(x == 6 || y == 3);
결과:
false
true
true
true
🥶NOT演算子(!)trueはfalse、falseはtrue
var x = 6;
var y = 3;
document.getElementById("demo").innerHTML =
!(x === y) + "<br>" +
!(x > y);
결과:
true
false
🥶3つの演算子(?)function myFunction() {
var age, voteable;
age = document.getElementById("age").value;
voteable = (age < 18) ? "Too young":"Old enough";
document.getElementById("demo").innerHTML = voteable + " to vote.";
18보다 낮으면 Too young.
18이상이면 Old enough to vote.
🐱🐉Conditions
🥶ドアが
条件が真の場合に実行
if (condition) {
// block of code to be executed if the condition is true
}
🥶ドア条件が偽の場合、実行
if (condition) {
// block of code to be executed if the condition is true
} else {
// block of code to be executed if the condition is false
}
🥶ドアが最初の条件が偽の場合、文を使用して新しい条件を指定します.
条件を細かくすることができます
if (condition1) {
// block of code to be executed if condition1 is true
} else if (condition2) {
// block of code to be executed if the condition1 is false and condition2 is true
} else {
// block of code to be executed if the condition1 is false and condition2 is false
}
JS-condition-ここに例を示します ex)
// 점수를 평가하여 A,B,C,D,F 등급으로 출력한다.
// 점수가 90이상이면 A
// 80이상이면 B
// 70이상이면 C
// 60이상이면 D
// 나머지(else) F
var su = 87;
if(su >= 90) {
document.write("A");
}else if(su >= 80) {
document.write("B");
}else if(su >= 70) {
document.write("C");
}else if(su >= 60){
document.write("D");
}else {
document.write("F");
}
결과: B
🐱🐉Switch
switch(expression) {
case x:
// code block
break;
case y:
// code block
break;
default:
// code block
}
ex)
var grade = "B"; // A, B, C, D 4개 값중에 하나가 선택
switch(grade) {
case "A":
document.write("A");
break;
case "B":
document.write("B");
break;
case "C":
document.write("C")
break;
case "D":
document.write("D")
}
document.write("종료");
결과: B종료
🐱🐉リファレンス
w3schools - JS
Reference
この問題について(20.12.08-12日), 我々は、より多くの情報をここで見つけました https://velog.io/@ham6482/20.12.08-12일차テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol