// 値
var v;
var v = '';
var v = 0;
var v = '0';
var v = null;
var v = 'null';
var v = undefined;
var v = 'undefined';
var v = [];
// console
console.log('v:' + v);
#条件が空文字
値 | console | if(v) | if(v == '') | if(v === '') | if(!v) | if(v != '') | if(v !== '') |
---|---|---|---|---|---|---|---|
v | value:undefined | false | false | false | true | true | true |
v = '' | value: | false | true | true | true | false | false |
v = 0 | value:0 | false | true | false | true | false | true |
v = '0' | value:0 | true | false | false | false | true | true |
v = null | value:null | false | false | false | true | true | true |
v = 'null' | value:null | true | false | false | false | true | true |
v = undefined | value:undefined | false | false | false | true | true | true |
v = 'undefined' | value:undefined | true | false | false | false | true | true |
v = [] | value: | true | true | false | false | false | true |
#条件がnull
値 | console | if(v == null) | if(v === null) | if(v != null) | if(v !== null) |
---|---|---|---|---|---|
v | value:undefined | true | false | false | true |
v = '' | value: | false | false | true | true |
v = 0 | value:0 | false | false | true | true |
v = '0' | value:0 | false | false | true | true |
v = null | value:null | true | true | false | false |
v = 'null' | value:null | false | false | true | true |
v = undefined | value:undefined | true | false | false | true |
v = 'undefined' | value:undefined | false | false | true | true |
v = [] | value: | false | false | true | true |
#条件がundefined
値 | console | if(v == undefined) | if(v === undefined) | if(v != undefined) | if(v !== undefined) |
---|---|---|---|---|---|
v | value:undefined | true | true | false | false |
v = '' | value: | false | false | true | true |
v = 0 | value:0 | false | false | true | true |
v = '0' | value:0 | false | false | true | true |
v = null | value:null | true | false | false | true |
v = 'null' | value:null | false | false | true | true |
v = undefined | value:undefined | true | true | false | false |
v = 'undefined' | value:undefined | false | false | true | true |
v = [] | value: | false | false | true | true |