<body>
<p id="test1"></p>
<p id="test2"></p>
<script>
var dateTest = new Date();
var arrayTest = ["i","am","array"];
var pTest1 = document.getElementById("test1");
var pTest2 = document.getElementById("test2");
pTest1.innerHTML = isDate(dateTest);
pTest2.innerHTML = isArray(arrayTest);
// Date判別メソッド
function isDate(date){
var result = date.constructor.toString().indexOf("Date") > -1;
return result;
}
// Array判別メソッド
function isArray(array){
var result = array.constructor.toString().indexOf("Array") > -1;
return result;
}
</script>
</body>
// 結果
true
true
More than 1 year has passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme