Skip to content

Instantly share code, notes, and snippets.

@magnet88jp
Created September 4, 2015 12:40
Show Gist options
  • Save magnet88jp/6cfc0f467aff0514f650 to your computer and use it in GitHub Desktop.
Save magnet88jp/6cfc0f467aff0514f650 to your computer and use it in GitHub Desktop.
javascipt (hoge != null && hoge.length > 0)
<html>
<head>
</head>
<body>
<h1>test</h1>
<script>
var aaa = '';
var bbb = '0';
var ccc = '1';
var ddd;
var eee = null;
var fff = ' ';
var ggg = 0;
var hhh = 1;
var test = !!(aaa) ? aaa : 'ng';
console.log('aaa='+ test);
test = !!(bbb) ? bbb : 'ng';
console.log('bbb='+ test);
test = !!(ccc) ? ccc : 'ng';
console.log('ccc='+ test);
test = !!(ddd) ? ddd : 'ng';
//test = (ddd != null && ddd.length > 0) ? ddd : 'ng';
console.log('ddd='+ test);
test = !!(eee) ? eee : 'ng';
console.log('eee='+ test);
test = !!(fff) ? fff : 'ng';
console.log('fff='+ test);
//test = !!(ggg) ? ggg : 'ng';
test = (ggg != null && ggg.length > 0) ? ddd : 'ng';
console.log('ggg='+ test);
test = !!(hhh) ? hhh : 'ng';
console.log('hhh='+ test);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment