print type of value
ini untuk proving type value negative
by oktaviardi pratama
HTML
<h1>
print type of value
</h1>
JavaScript
let test = undefined
let test2 = null
let test3 = true
let test4 = []
let test5 = {}
let test6 = false
let test7 = 0
function print(val) {
if(!val) {
console.log('negative validation included for: '+val)
}
}
print(test);
print(test2);
print(test3);
print(test4);
print(test5);
print(test6);
print(test7);
console.log(typeof ""); // ποΈ "string"
console.log(typeof "hello"); // ποΈ "string"
console.log(typeof "42"); // ποΈ "string"
console.log(typeof function () {}); // ποΈ "function"
console.log(typeof null); // ποΈ "object"
console.log(typeof []); // ποΈ "object"
console.log(typeof {}); // ποΈ "object"
console.log(typeof 0); // ποΈ "number"