0
Help us understand the problem. What are the problem?

posted at

updated at

# JavaScript

1、boolean型
boolean型と＝trueかfalseを代入できる変数の事。

``````let b = false;
if(b){
console.log('はい');
}else{
console.log('いいえ');
}

console.log(b); →false
console.log(!b); →true
``````

２、論理演算子

``````&& 論理AND=AとBがあったら両方trueの場合trunを返す
console.log(true && true);　　→true
console.log(true && false);  →false
console.log(false && true);  →false
console.log(false && false); →false

||論理OR=論理値AとBがあったらどちらかがtrueの場合trueを返す
console.log(true || true);　　→true
console.log(true || false);  →true
console.log(false || true);  →true
console.log(false || false); →false

!論理NOT＝論理値を反転させる
console.log(!true); →false
console.log(!false); →true

! && ||
console.log(false && true || true); →true
console.log(false && (true || true))　→false

３、nullとundefined

//undefined
let x;
console.log(x);　→undefined

let item = y;
``````

４、三項演算子

``````//条件式? trueの場合:falseの場合
(例題)
let score = 70;
let judgement = (score > 50) ? '合格' : '不合格';
console.log(judgement);　→合格
``````

５、コールバック関数

``````function greeting(name){
console.log('Hello' + name + '-san');
}

let name = prompt('あなたの名前を入力してください');
callback(name);
}

``````

６、配列

``````let colors = ['red','green','blue'];
console.log(colors);　　→全ての配列を出力 red,green,blue
console.log(colors[0]); →１つ目の配列を出力 red

//個数
console.log(colors.length); →3

``````
Why not register and get more from Qiita?
1. We will deliver articles that match you
By following users and tags, you can catch up information on technical fields that you are interested in as a whole
2. you can read useful information later efficiently
By "stocking" the articles you like, you can search right away