Ejemplo de typeof javascript
En este ejemplo de javascript mostrare el uso del
operador typeof el cual permite conocer el tipo de un valor
devolviendo un string con el nombre del tipo
Pudiendo ser uno de los siguientes: "number", "string",
"boolean", "undefined", "object" y "function".
aquí un ejemplo:
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<script type="text/javascript">
document.write("typeof 100: "+typeof 100);//number
document.write("<br>typeof appletenhtml: "+typeof "appletenhtml");//string
document.write("<br>typeof false: "+typeof false);
document.write("<br>typeof undefined: "+typeof undefined);//boolean
document.write("<br>typeof null: "+typeof null);//undefined
document.write("<br>typeof new Date(): "+typeof new Date());//object
document.write("<br>typeof new Function: "+typeof new Function());//function
</script>
</body>
</html>
Ejecutar ejemplo: typeof javascript
Descargar ejemplo: typeof javascript
Comentarios
Publicar un comentario