Skip to content

Instantly share code, notes, and snippets.

View Ifmr24's full-sized avatar
😄

Fabian Mesias Ifmr24

😄
  • Santiago
  • 08:53 (UTC -04:00)
View GitHub Profile
@Ifmr24
Ifmr24 / js_querySelector.js
Last active September 17, 2018 21:01
JS Query Selector
document.querySelector('#').addEventListener('click', function(){
nombredefuncion();
});
@Ifmr24
Ifmr24 / a.js
Last active September 17, 2018 21:52
JS Variable VAR
// 1 - VARIABLES.
var pais = 'Chile'; // String
var continente = 'Latino America'; // String
var antiguedad = 2018; // Entero
var pais_y_continente = pais + ' ' + continente // Cadena
@Ifmr24
Ifmr24 / a.js
Last active September 17, 2018 21:51
JS Variable VAR / CambiarValor
// 1 - VARIABLES.
var pais = 'Chile'; // String
var continente = 'Latino America'; // String
var antiguedad = 2018; // Entero
var pais_y_continente = pais + ' ' + continente // Cadena
// 2 - CAMBIAR VALOR A VARIABLE A NIVEL GLOBAL // EL VALOR DE pais_y_continente NO SE CAMBIARA.
pais = 'Mexico';
@Ifmr24
Ifmr24 / a.js
Last active September 17, 2018 21:51
JS Variable LET
// 3 - VARIABLES LET // LET FUNCIONA A NIVEL DE BLOQUE, NO A NIVEL GLOBAL.
//prueba con var
var numero = 40;
console.log(numero) // Mostrara 40 en consola.
if(true){
var numero = 50;
console.log(numero) // Mostrara 50 en consola.
}
@Ifmr24
Ifmr24 / a.js
Last active September 17, 2018 21:50
JS Variable Constante
// 4 - CONSTANTES - ES UNA VARIABLE, PERO SU VALOR NUNCA CAMBIARA
var web = "ingkf.com";
const ip = "67.23.253.165";
web = "dsfsdf.com"; //el valor cambiara
ip = "23123"; // el cambio de valor dara error, ya que ip fue declarada como constante, y estas no pueden cambiar
@Ifmr24
Ifmr24 / a.js
Created September 17, 2018 21:59
JS Tipos de Datos
// 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
@Ifmr24
Ifmr24 / a.js
Created September 17, 2018 22:59
JS Condicional IF y Operadores
// CONDICIONAL IF
// Si A es igual a B entonces haz algo
var a = 10;
var b = 10;
/*
//OPERADORES RELACIONALES
@Ifmr24
Ifmr24 / a.js
Last active September 17, 2018 23:09
JS Condicional Switch
// CONDICIONAL SWITCH
var edad = 18;
var imprime = "";
switch (edad) {
case 18:
imprime = "Tu edad es 18";
break;
case 20:
@Ifmr24
Ifmr24 / a.js
Created September 17, 2018 23:24
JS Bucle FOR
// BUCLE FOR
// BUCLE ES UNA ESTRUCTURA DE CONTROL QUE SE REPITE VARIAS VECES
// La variable numero sera el maximo de veces que se repetira el bucle
var numero = 100;
//Variable i sera el contador; mientras i sea menor o igual a numero(100) se repetira; incrementamos la variable i cada vez que se repita
for( var i = 1; i <= numero; i++ ){
console.log("Vamos por el numero: " + i );
}
@Ifmr24
Ifmr24 / a.js
Created September 18, 2018 00:10
JS Bucle While
// BUCLE WHILE
// BUCLE WHILE ES MENOS ESTRICTO QUE FOR
var year = 2018;
// Mientras que year sea igual o menor a 2051
while(year <= 2051){
//Ejecuta esto
console.log("Estamos en el año: "+year)
//Incrementamos la variable year para que cuando llegue a 2051 se pare el bucle