-
-
Save Ifmr24/d442d11c02665fba0264f73e6f1ccf6c to your computer and use it in GitHub Desktop.
JS Tipos de Datos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// OPERADORES | |
var num1 = 10; | |
var num2 = 10; | |
var operacion = num1 + num2; | |
console.log("El resultado es: " + operacion); | |
// TIPO DE DATOS | |
var numero_entero = 50; // Entero | |
var cadena_texto = 'Hola "que" tal' // String | |
var verdadero_o_falso = false; // Boleano: false o true o | |
// Transformar variable a otro tipo de dato | |
var numero_falso = "33"; // String | |
var numero = 33; | |
console.log( Number(numero_falso) ); // Transforma en String a Numero | |
console.log( parseInt(numero_falso) ); // Transforma en String a Entero | |
console.log( parseFloat(numero_falso) ); // Transforma en String a Flotante | |
console.log( String(numero) ); // Transforma Numero a String | |
// Saber que tipo de dato es una variable | |
console.log( typeof numero_falso ); // Dira que es de tipo String | |
console.log( typeof numero ); // Dira que es de tipo Entero |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment