<script type="text/javascript">
function saveName (firstName) {
function capitalizeName () {
return firstName.toUpperCase();
}
var capitalized = capitalizeName();console.log(capitalized instanceof String);
return capitalized;
}
console.log(saveName("Robert")); // Returns "ROBERT"
</script>
Question:
I want to check the type of capitalized , so I use capitalized instanceof String
? But it shows: false
in console, I do not want to try capitalized instanceof Function
, Object
...It will take too much time, so what is the best way to detect a variable type?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…