Programacion en la web

Páginas: 5 (1249 palabras) Publicado: 23 de agosto de 2012
ESTRUCTURA IF

*If(condición ) valida la condición {
*…
*}
Var mostrar Mensaje=true;
If(mostrar Mensaje){
alert(“Hola Mundo);
}
http://www.w3schools.com/js/tryit.asp?filename=tryjs_randomlink
<html>
<script type="text/javascript">
var mostrarMensaje=true;
if(mostrarMensaje){
alert("Hola Mundo");
}

</script>
<body>
</body>
</html>http://www.w3schools.com/js/tryit.asp?filename=tryjs_randomlink
<html>

<script type="text/javascript">
var mostrarMensaje=true;
if(mostrarMensaje==true){
alert("Hola Mundo");
}

</script>
<body>
</body>
</html>
http://www.w3schools.com/js/tryit.asp?filename=tryjs_randomlink
<html>

<script type="text/javascript">
var mostrado=false;
varusuarioPermiteMensajes=true;
if(!mostrado&&usuarioPermiteMensajes){
alert("Es la primera vez que se muestra el mensaje");
}

</script>
<body>
</body>
</html>

http://www.w3schools.com/js/tryit.asp?filename=tryjs_randomlink

<html>

<script type="text/javascript">
var numero1=5;
var numero2=8;
resultado
if(){
alert("numero1 no es mayorque numero2");
}
if(...){
alert("numero2 es positivo");
}
if(...){
alert("numero1 es negativo o distinto de cero");
}
if(...){
alert("incrementar en 1 unidad el valor de numero1 no lo hace mayor o igual que numero2");
}
</script>
<body>
</body>
</html>

ESTRUCTURA IF…ELSE
<html>

<script type="text/javascript">
var edad=18;
if(edad>=18){alert("Eres mayor de edad");
}
else{
alert("Todavia eres menor de edad");
}
</script>
<body>
</body>
</html>
ESTRUCTURA IF…ELSE anidado
<html>

<script type="text/javascript">
var edad=18;
if(edad<12){
alert("Todavia eres muy pequeño");
}
else if(edad<19){
alert("Eres un adolescente");
}
else if(edad<35){
alert("Aun sigues siendojoven");
}
else{
alert("Piensa bien cuidarte un poco mas");
}

</script>
<body>
</body>
</html>

ESTRUCTURA FOR
<html>

<script type="text/javascript">
var mensaje ="bucle";
for(vari=0;i<5;i++){
alert(“hola mundo”);
}
</script>
<body>
</body>
</html>

El factorial de un numero entero n es una operación matemáticaque consiste en multiplicar todos los factores nx( n-1)x(n-2)x…..x1.
Así, el factorial de 5 (escrito como 5!) es igual a: 5!= 5x
4x3x2x1=120.
Utilizando la estructura for
ESTRUCTURA FOR…IN
por lo general se usa para recorrer arreglos
for(índice in array )

GENERAL
<html>
<body>

<script type="text/javascript">
vardias=["lunes","martes","miercoles","jueves","viernes","sabado","domingo"];
for(i in dias){
alert(dias[i]);
}
</script>

</body>
</html>

Funciones y propiedades basicas de javascript

LENGTH

var mensaje=” Hola Mundo”;
var numeroLetras=mensaje.length;//numeroLetras=10

+ SIRVE PARA CONCATENAR
var mensaje1=”Hola”;
var mensaje2=”Mundo”;
var mensaje=mensaje+mensaje2;//mensaje=”Hola Mundo”
toUpperCase()

varmensaje1=”Hola”;
var mensaje2=mensaje1.toUpperCase();//mensaje2=”HOLA”
COMO BUENA PRACTICA LOS METODOSSE INICIAN CON MINUSCULAS Y CADA PALABRASIGUIENTE EN MAYUSCULAS

POP
<html>
<body>

<script type="text/javascript">
var array =[1,2,3];
var ultimo=array.pop();
alert(ultimo);
</script>

</body>
</html>

PUSH
<html>
<body><script type="text/javascript">
var array =[1,2,3];
var ultimo=array.push(4);
//ahora array=[1,2,3,4]
alert(ultimo);
</script>

</body>
</html>
SHIFT
<html>
<body>

<script type="text/javascript">
var array =[1,2,3];
var primero=array.shift();
//ahora array=[1,2,3,4]
alert(primero);
</script>

</body>
</html>...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Programacion web
  • Programacion web
  • Programacion web
  • Programacion Web
  • Programacion Web
  • Programacion web
  • Programacion web
  • programacion web

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS