0%

RN笔记

语法

1.some test

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

let a = {o: "091"}
a['8'] = "90"
a[Symbol.iterator] = function* () {
yield 1;
yield 2;
yield 3;
};
Object.getPrototypeOf(a).a = 898
let b = Object.create(a)
Object.getPrototypeOf(b).a = 666
let car = new Car("ma","mo","ye")
//Object.getOwnPropertyNames(Object.getPrototypeOf(a))
console.log(Object.getOwnPropertyNames(Object.getPrototypeOf(car)));

function showProps(obj, objName) {
var result = "";
for (var i in obj) {
if (obj.hasOwnProperty(i)) {
result += objName + "." + i + " = " + obj[i] + "\n";
}
}
return result;
}

function Car(make, model, year) {
this.make = make;
this.model = model;
this.year = year;
}

function forProps(obj) {
let object = obj;
let resullt = ""
do {
object = Object.getPrototypeOf(object);
resullt += object +"\n"
} while (object);
return resullt

}

function* fibonacci() {
let a = 0, b = 1;
while (true) {
yield b;
[a, b] = [b, a + b];
}
}
  1. 1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    function a() {
    }

    function B() {
    this.b = "12"
    }

    class C {
    e() {
    }
    }

    let d = {}
    console.log(B.__proto__ === Object.getPrototypeOf(B))
    // new B().__proto__ === Object.getPrototypeOf(new B())
    // B.prototype === Object.getPrototypeOf(new B())
    // B.prototype["constructor"] === B
    // Object.getPrototypeOf(new B())["constructor"] === B
    // B.__proto__ === Object.getPrototypeOf(B)
    // B.__proto__ != B.prototype // Object.getPrototypeOf(B) 为 function (){ [native code] } , 而 Object.getPrototypeOf(new B()) === B.prototype 为 {constructor:B}
    // 以上同样规则 使用a 与 C .只是C.prototype 为 {constructor:C,e:(){}},多了C的成员函数的变量。如果想让B与C达到一样,只需B.prototype.e = function (){}即可
    ````
    2.`...`eg: