Академический Документы
Профессиональный Документы
Культура Документы
Output:
document.
document.getElementById('IdEtiqueta').propiedad =
document.getElementById('demo').innerHTML = cambia contenido etiqueta
document.getElementById('myImage').src = cambia src de la etiqueta
document.getElementById('demo').style.fontSize='35p = cambia estilo css
Sintaxis:
Decalarando variable
var x, y, z;
x = 5;
y = 6;
z = x + y;
"John Doe"
‘John Doe’
Concatenar
El tipo de sintaxis es
CamelCase.
Peculiar:
var y = 123e5; // 12300000
var z = 123e-5; // 0.00123
_______________________________________________________________________________
var person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};
person = null; // Now value is null, but type is still an object
var person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};
person = undefined; // Now both value and type is undefined
______________________________________________________________________________________
debugger Stops the execution of JavaScript, and calls (if available) the
debugging function
do ... while Executes a block of statements, and repeats the block, while a
condition is true
Comentarios:
/*
esto es un comentario multilinea en javascript
*/
Operadores:
Operator Description
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus (Remainder)
++ Increment
-- Decrement
Operator Description
= x=y x=y
+= x += y x=x+y
-= x -= y x=x-y
*= x *= y x=x*y
/= x /= y x=x/y
%= x %= y x=x%y
Operator Description
== equal to
!= not equal
18 . Member person.name
18 [] Member person["name"]
14 * Multiplication 10 * 5
14 / Division 10 / 5
14 % Modulo division 10 % 5
14 ** Exponentiation 10 ** 2
13 + Addition 10 + 5
13 - Subtraction 10 - 5
10 == Equal x == y
10 != Unequal x != y
3 = Assignment x=y
3 += Assignment x += y
3 -= Assignment x -= y
3 *= Assignment x *= y
3 %= Assignment x %= y
3 ^= Assignment x ^= y
3 |= Assignment x |= y
Tipos de Datos:
string
number
boolean
undefined
function
object
/*
*/
<script>
var person = {
firstName: "John",
lastName : "Doe",
id : 5566,
fullName : function() {
return this.firstName + " " + this.lastName;
}
};
document.getElementById("demo").innerHTML = person.fullName;
</script>
<script>
var x = myFunction(4, 3);
document.getElementById("demo").innerHTML = x;
function myFunction(a, b) {
return a * b;
}
</script>
Scope:
Modelo 1
// code here can not use carName
function myFunction() {
var carName = "Volvo";
// code here can use carName}
Modelo 2
var carName = " Volvo";
// code here can use carName
function myFunction() { // code here can use carName }
Modelo 3
myFunction();
// code here can use carName
function myFunction() { carName = "Volvo";}
Modelo 4
var carName = "Volvo";
// code here can use window.carName
document.getElementById("demo").innerHTML = "I can display " + window.carName;
La propiedad THIS:
this.innerHTML = Date();
//escribe la fecha actual ej: Fri Dec 29 2017 22:03:12 GMT-0400 (Hora estándar de
Venezuela)
Eventos en Javascript:
Mouse Events
Event Descripcion