-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path02-object javascript.txt
51 lines (45 loc) · 969 Bytes
/
02-object javascript.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//Tipo y el constructor
//<2015->ES5
function Foo(name){
this.name = name
}
//metodo publico
Foo.prototype.write = function(){
this._write()
}
//metodo privado
Foo.prototype._write = function(){
console.log(this.name)
}
Foo.write = function(){
console.log("static method")
}
>2015->ES6
//azucar sintactico
class Foo{
constructor(name){
this.name = name
}
_write(){
console.log(this.name)
}
write(){
this._write()
}
static write(){
console.log("static method")
}
}
//Transpilacion
/*
Babel->React,Vue
TypeScript->Microsoft
*/
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes
https://github.com/tc39/ecma262
https://developer.mozilla.org/es/docs/Web/JavaScript/Inheritance_and_the_prototype_chain
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function
function sum(a,b){
return a+b
}
diferencias null vs undefined