diff --git a/zh-cn/application-dev/reference/apis/js-apis-arraylist.md b/zh-cn/application-dev/reference/apis/js-apis-arraylist.md index 47fe1ca88cdadc08ade5db3f1bfd89dcad9bbd68..fa14e6490a7befdf21316d17c6c55fd55ba34120 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-arraylist.md +++ b/zh-cn/application-dev/reference/apis/js-apis-arraylist.md @@ -456,7 +456,7 @@ arrayList.add(2); arrayList.add(4); arrayList.add(5); arrayList.add(4); -arrayList.forEach((value: number, index: number) => { +arrayList.forEach((value: number, index?: number) => { console.log("hyq value:" + value, "index:" + index); }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-buffer.md b/zh-cn/application-dev/reference/apis/js-apis-buffer.md index 21f9ec032803a1ccfa2d18123d7f9213fd2eb9f0..86b5ae373bed01dc6317b3a077c2c62ccd5abca9 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-buffer.md +++ b/zh-cn/application-dev/reference/apis/js-apis-buffer.md @@ -634,9 +634,9 @@ import buffer from '@ohos.buffer'; let buf = buffer.from('buffer'); let pair = buf.entries() -let next = pair.next() +let next: IteratorResult = pair.next() while (!next.done) { - console.info(next.value) + console.info("buffer: " + next.value) next = pair.next() } ``` @@ -1963,7 +1963,7 @@ import buffer from '@ohos.buffer'; let buf1 = buffer.from('buffer'); let pair = buf1.values() -let next = pair.next() +let next:IteratorResult = pair.next() while (!next.done) { console.log(next.value.toString()); next = pair.next() @@ -2923,8 +2923,8 @@ import buffer from '@ohos.buffer'; let blob: buffer.Blob = new buffer.Blob(['a', 'b', 'c']); class option { - endings: string - type: string + endings: string = "" + type: string = "" } let o1: option = {endings:'native', type: 'MIME'} let blob1: buffer.Blob = new buffer.Blob(['a', 'b', 'c'], o1); diff --git a/zh-cn/application-dev/reference/apis/js-apis-deque.md b/zh-cn/application-dev/reference/apis/js-apis-deque.md index 78cd11dee5ca7ced1a340937bacc6ad3c3f23818..1d7a42346db7f62a5904eeeeb905cc2dabb959f2 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-deque.md +++ b/zh-cn/application-dev/reference/apis/js-apis-deque.md @@ -119,8 +119,8 @@ insertEnd(element: T): void ```ts class C1 { - name: string - age: string + name: string = "" + age: string = "" } let deque: Deque | C1> = new Deque(); @@ -277,7 +277,7 @@ deque.insertFront(2); deque.insertEnd(4); deque.insertFront(5); deque.insertEnd(4); -deque.forEach((value: number, index: number) => { +deque.forEach((value: number, index?: number | undefined, deque?: Deque | undefined):void => { console.log("value:" + value, "index:" + index); }); ``` @@ -386,9 +386,9 @@ for (let item of nums) { // 使用方法二: let iter = deque[Symbol.iterator](); -let temp = iter.next().value; -while(temp != undefined) { - console.log("value:" + temp); - temp = iter.next().value; +let temp:IteratorResult = iter.next(); +while(!temp.done) { + console.log("value:" + temp.value); + temp = iter.next(); } ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-hashmap.md b/zh-cn/application-dev/reference/apis/js-apis-hashmap.md index 3b7d17589fb1468c435cbf286913c2a3a3b94369..7fdf5741a77349cb602a179a379595cefdee8386 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hashmap.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hashmap.md @@ -363,7 +363,7 @@ let hashMap: HashMap = new HashMap(); hashMap.set("squirrel", 123); hashMap.set("sparrow", 356); let iter = hashMap.keys(); -let temp = iter.next(); +let temp: IteratorResult = iter.next(); while(!temp.done) { console.log("value:" + temp.value); temp = iter.next(); @@ -400,7 +400,7 @@ let hashMap: HashMap = new HashMap(); hashMap.set("squirrel", 123); hashMap.set("sparrow", 356); let iter = hashMap.values(); -let temp = iter.next(); +let temp: IteratorResult = iter.next(); while(!temp.done) { console.log("value:" + temp.value); temp = iter.next(); @@ -482,7 +482,7 @@ callbackfn的参数说明: let hashMap: HashMap = new HashMap(); hashMap.set("sparrow", 123); hashMap.set("gull", 357); -hashMap.forEach((value: number, key: string) => { +hashMap.forEach((value?: number, key?: string) => { console.log("value:" + value, "key:" + key); }); ``` @@ -517,7 +517,7 @@ let hashMap: HashMap = new HashMap(); hashMap.set("squirrel", 123); hashMap.set("sparrow", 356); let iter = hashMap.entries(); -let temp = iter.next(); +let temp: IteratorResult = iter.next(); while(!temp.done) { console.log("key:" + temp.value[0]); console.log("value:" + temp.value[1]); @@ -555,14 +555,14 @@ hashMap.set("squirrel", 123); hashMap.set("sparrow", 356); // 使用方法一: -for (let item of hashMap) { - console.log("key:" + item[0]); - console.log("value:" + item[1]); +for (let key of keys) { + console.log("key:" + key); + console.log("value:" + hashMap.get(key)); } // 使用方法二: let iter = hashMap[Symbol.iterator](); -let temp = iter.next().value; +let temp: IteratorResult = iter.next().value; while(temp != undefined) { console.log("key:" + temp[0]); console.log("value:" + temp[1]); diff --git a/zh-cn/application-dev/reference/apis/js-apis-hashset.md b/zh-cn/application-dev/reference/apis/js-apis-hashset.md index c005c709c1d7622e76a0daa2e5ec4023462a957f..36027747105e05f1a35130fe253e426309b53fba 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hashset.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hashset.md @@ -305,7 +305,7 @@ callbackfn的参数说明: let hashSet: HashSet = new HashSet(); hashSet.add("sparrow"); hashSet.add("squirrel"); -hashSet.forEach((value: string, key: string) => { +hashSet.forEach((value?: string, key?: string): void => { console.log("value:" + value, "key:" + key); }); ``` @@ -339,7 +339,7 @@ let hashSet: HashSet = new HashSet(); hashSet.add("squirrel"); hashSet.add("sparrow"); let iter = hashSet.entries(); -let temp = iter.next(); +let temp: IteratorResult = iter.next(); while(!temp.done) { console.log("key:" + temp.value[0]); console.log("value:" + temp.value[1]); @@ -385,7 +385,7 @@ for (let item of val) { // 使用方法二: let iter = hashSet[Symbol.iterator](); -let temp = iter.next(); +let temp: IteratorResult = iter.next(); while(!temp.done) { console.log("value: " + temp.value); temp = iter.next(); diff --git a/zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md b/zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md index 8fba1f137b9d741627a716cf9e151fa42e276469..846ad3a55cd266e7cc112c81a8d970f2813f2dba 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md +++ b/zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md @@ -666,7 +666,7 @@ let lightWeightMap: LightWeightMap = new LightWeightMap(); lightWeightMap.set("squirrel", 123); lightWeightMap.set("sparrow", 356); let iter = lightWeightMap.keys(); -let temp = iter.next(); +let temp: IteratorResult = iter.next(); while(!temp.done) { console.log("value:" + temp.value); temp = iter.next(); @@ -703,7 +703,7 @@ let lightWeightMap: LightWeightMap = new LightWeightMap(); lightWeightMap.set("squirrel", 123); lightWeightMap.set("sparrow", 356); let iter = lightWeightMap.values(); -let temp = iter.next(); +let temp: IteratorResult = iter.next(); while(!temp.done) { console.log("value:" + temp.value); temp = iter.next(); @@ -747,7 +747,7 @@ callbackfn的参数说明: let lightWeightMap: LightWeightMap = new LightWeightMap(); lightWeightMap.set("sparrow", 123); lightWeightMap.set("gull", 357); -lightWeightMap.forEach((value: number, key: string) => { +lightWeightMap.forEach((value?: number, key?: string) => { console.log("value:" + value, "key:" + key); }); ``` @@ -782,7 +782,7 @@ let lightWeightMap: LightWeightMap = new LightWeightMap(); lightWeightMap.set("squirrel", 123); lightWeightMap.set("sparrow", 356); let iter = lightWeightMap.entries(); -let temp = iter.next(); +let temp: IteratorResult = iter.next(); while(!temp.done) { console.log("key:" + temp.value[0]); console.log("value:" + temp.value[1]); @@ -863,7 +863,7 @@ for (let item2 of key) { // 使用方法二: let iter = lightWeightMap[Symbol.iterator](); -let temp = iter.next(); +let temp: IteratorResult = iter.next(); while(!temp.done) { console.log("key:" + temp.value[0]); console.log("value:" + temp.value[1]); diff --git a/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md b/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md index a17e0d730b7f1908159818ce6aa73cdd19fdfabf..4b9f2e180bad7670d3dac63bdfbb87ae161858ad 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md +++ b/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md @@ -611,7 +611,7 @@ callbackfn的参数说明: let lightWeightSet: LightWeightSet = new LightWeightSet(); lightWeightSet.add("sparrow"); lightWeightSet.add("gull"); -lightWeightSet.forEach((value:string, key:string) => { +lightWeightSet.forEach((value ?: string, key ?: string) => { console.log("value:" + value, "key:" + key); }); ``` @@ -691,7 +691,7 @@ for (let item of nums) { // 使用方法二: let iter = lightWeightSet[Symbol.iterator](); -let temp = iter.next(); +let temp: IteratorResult = iter.next(); while(!temp.done) { console.log("value:" + temp.value); temp = iter.next(); diff --git a/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md b/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md index 366052f94e8c9a8356bc50a6fdbf34d58d92869d..865946c1fd8d29cd7d015bea624638e576774cf9 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md +++ b/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md @@ -641,7 +641,7 @@ linkedList.add(2); linkedList.add(4); linkedList.add(5); linkedList.add(4); -linkedList.forEach((value:number, index: number) => { +linkedList.forEach((value: number, index?: number) => { console.log("value:" + value, "index:" + index); }); ``` @@ -851,7 +851,7 @@ for (let item of items) { // 使用方法二: let iter = linkedList[Symbol.iterator](); -let temp = iter.next(); +let temp: IteratorResult = iter.next(); while(!temp.done) { console.log("value:" + temp.value); temp = iter.next(); diff --git a/zh-cn/application-dev/reference/apis/js-apis-list.md b/zh-cn/application-dev/reference/apis/js-apis-list.md index f151ac9e52a76cf398aecc1252e471c35bc54b43..69c2d4312e7f8bd89c11aed9dd299e2c163bb202 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-list.md +++ b/zh-cn/application-dev/reference/apis/js-apis-list.md @@ -503,7 +503,7 @@ list.add(2); list.add(4); list.add(5); list.add(4); -list.forEach((value:number, index:number) => { +list.forEach((value: number, index?: number) => { console.log("value:" + value, "index:" + index); }); ``` @@ -829,7 +829,7 @@ for (let item of items) { // 使用方法二: let iter = list[Symbol.iterator](); -let temp = iter.next(); +let temp: IteratorResult = iter.next(); while(!temp.done) { console.log("value: " + temp.value); temp = iter.next(); diff --git a/zh-cn/application-dev/reference/apis/js-apis-plainarray.md b/zh-cn/application-dev/reference/apis/js-apis-plainarray.md index 654ca7fffe9973041f3e25973505e5edc5165f38..cee70aef8d6f1810ca4282481d59b4d6dbd694fc 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-plainarray.md +++ b/zh-cn/application-dev/reference/apis/js-apis-plainarray.md @@ -620,7 +620,7 @@ callbackfn的参数说明: let plainArray: PlainArray = new PlainArray(); plainArray.add(1, "squirrel"); plainArray.add(2, "sparrow"); -plainArray.forEach((value:string, index: number) => { +plainArray.forEach((value: string, index?: number) => { console.log("value:" + value, "index:" + index); }); ``` @@ -656,7 +656,7 @@ plainArray.add(1, "squirrel"); plainArray.add(2, "sparrow"); let iter = plainArray[Symbol.iterator](); -let temp = iter.next(); +let temp: IteratorResult = iter.next(); while(!temp.done) { console.log("key:" + temp.value[0]); console.log("value:" + temp.value[1]); diff --git a/zh-cn/application-dev/reference/apis/js-apis-queue.md b/zh-cn/application-dev/reference/apis/js-apis-queue.md index 4d5d035a775eeb6645af22f5ece39aedaed1f955..a4626d65975b9e30f7935d40a72055e29b58a1ea 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-queue.md +++ b/zh-cn/application-dev/reference/apis/js-apis-queue.md @@ -206,7 +206,7 @@ queue.add(2); queue.add(4); queue.add(5); queue.add(4); -queue.forEach((value : number, index : number) : void => { +queue.forEach((value : number, index ?: number) : void => { console.log("value:" + value, "index:" + index); }); ``` @@ -249,7 +249,7 @@ while(queue.length) { // 使用方法二: let iter = queue[Symbol.iterator](); -let temp = iter.next().value; +let temp: IteratorResult = iter.next().value; while(temp != undefined) { console.log("value:" + temp); temp = iter.next().value; diff --git a/zh-cn/application-dev/reference/apis/js-apis-stack.md b/zh-cn/application-dev/reference/apis/js-apis-stack.md index f8f3db16bc3f2d205c94c0aaca34ae13247e30df..69845d5a8959e7b9b0a70622b6cd933aed51725d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-stack.md +++ b/zh-cn/application-dev/reference/apis/js-apis-stack.md @@ -244,7 +244,7 @@ stack.push(2); stack.push(4); stack.push(5); stack.push(4); -stack.forEach((value : number, index : number) :void => { +stack.forEach((value : number, index ?: number) :void => { console.log("value:" + value, "index:" + index); }); ``` @@ -321,7 +321,7 @@ while(!stack.isEmpty()) { // 使用方法二: let iter = stack[Symbol.iterator](); -let temp = iter.next().value; +let temp: IteratorResult = iter.next().value; while(temp != undefined) { console.log("value:" + temp); temp = iter.next().value; diff --git a/zh-cn/application-dev/reference/apis/js-apis-treemap.md b/zh-cn/application-dev/reference/apis/js-apis-treemap.md index b8ebb8f4696687555f293e8e8d2b02660a582d28..22b7aff92b65208d948070dcfd81984bcad6964a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-treemap.md +++ b/zh-cn/application-dev/reference/apis/js-apis-treemap.md @@ -302,7 +302,7 @@ treeMap.set("sparrow", 356); let map : TreeMap = new TreeMap(); map.set("demo", 12); map.setAll(treeMap); // 将treeMap中的所有元素添加到map中 -map.forEach((value : number, key : string) : void => { +map.forEach((value ?: number, key ?: string) : void => { console.log("value" + value, "key" + key); // 打印结果 12 demo、356 sparrow、123 squirrel }) ``` @@ -553,9 +553,9 @@ let treeMap : TreeMap = new TreeMap(); treeMap.set("squirrel", 123); treeMap.set("sparrow", 356); let it = treeMap.values(); -let t = it.next(); +let t: IteratorResult = it.next(); while(!t.done) { - console.log(t.value); + console.log("TreeMap" + t.value); t = it.next() } ``` @@ -590,9 +590,9 @@ let treeMap : TreeMap = new TreeMap(); treeMap.set("squirrel", 123); treeMap.set("sparrow", 356); let it = treeMap.values(); -let t = it.next(); +let t: IteratorResult = it.next(); while(!t.done) { - console.log(t.value); + console.log("TreeMap" + t.value); t = it.next() } ``` @@ -634,7 +634,7 @@ callbackFn的参数说明: let treeMap : TreeMap = new TreeMap(); treeMap.set("sparrow", 123); treeMap.set("gull", 357); -treeMap.forEach((value : number, key : string) : void => { +treeMap.forEach((value ?: number, key ?: string) : void => { console.log("value:" + value, "key:" + key); }); ``` @@ -669,9 +669,9 @@ let treeMap : TreeMap = new TreeMap(); treeMap.set("squirrel", 123); treeMap.set("sparrow", 356); let it = treeMap.entries(); -let t = it.next(); +let t: IteratorResult = it.next(); while(!t.done) { - console.log(t.value); + console.log("TreeMap" + t.value); t = it.next() } ``` @@ -707,14 +707,14 @@ treeMap.set("sparrow", 356); // 使用方法一: let it = treeMap.entries(); -let t = it.next(); +let t: IteratorResult = it.next(); while(!t.done) { - console.log(t.value); + console.log("TreeMap" + t.value); t = it.next() // 使用方法二: let iter = treeMap[Symbol.iterator](); -let temp = iter.next().value; +let temp: IteratorResult = iter.next().value; while(temp != undefined) { console.log("key:" + temp[0]); console.log("value:" + temp[1]); diff --git a/zh-cn/application-dev/reference/apis/js-apis-treeset.md b/zh-cn/application-dev/reference/apis/js-apis-treeset.md index 15d2f21484e732428c828e95925b925929f5231c..7737c82bd32efe873fa68bb357baa3ea2434696b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-treeset.md +++ b/zh-cn/application-dev/reference/apis/js-apis-treeset.md @@ -462,9 +462,9 @@ let treeSet : TreeSet = new TreeSet(); treeSet.add("squirrel"); treeSet.add("sparrow"); let it = treeSet.values(); -let t = it.next(); +let t: IteratorResult = it.next(); while(!t.done) { - console.log(t.value); + console.log("TreeSet: " + t.value); t = it.next() } ``` @@ -506,7 +506,7 @@ callbackFn的参数说明: let treeSet : TreeSet = new TreeSet(); treeSet.add("sparrow"); treeSet.add("gull"); -treeSet.forEach((value : string, key : string) :void => { +treeSet.forEach((value ?: string, key ?: string) :void => { console.log("value:" + value, "key:" + key); }); ``` @@ -541,9 +541,9 @@ let treeSet : TreeSet = new TreeSet(); treeSet.add("squirrel"); treeSet.add("sparrow"); let it = treeSet.entries(); -let t = it.next(); +let t: IteratorResult = it.next(); while(!t.done) { - console.log(t.value); + console.log("TreeSet: " + t.value); t = it.next() } ``` @@ -585,7 +585,7 @@ for (let item of numbers) { } // 使用方法二: let iter = treeSet[Symbol.iterator](); -let temp = iter.next().value; +let temp: IteratorResult = iter.next().value; while(temp != undefined) { console.log("value:" + temp); temp = iter.next().value; diff --git a/zh-cn/application-dev/reference/apis/js-apis-vector.md b/zh-cn/application-dev/reference/apis/js-apis-vector.md index a01b694cf650e4f7b57f7b33d549ae00f44975fd..f5ab7b7de09e2b4f11b78cd3d5bc4694d6d869e2 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-vector.md +++ b/zh-cn/application-dev/reference/apis/js-apis-vector.md @@ -44,7 +44,7 @@ Vector的构造函数。 **示例:** ```ts -let vector : Vector> = new Vector(); +let vector : Vector> = new Vector(); ``` @@ -359,12 +359,12 @@ callbackfn的参数说明: **示例:** ```ts -let vector : Vector> = new Vector(); +let vector : Vector = new Vector(); vector.add(2); vector.add(4); vector.add(5); vector.add(4); -vector.forEach((value : Vector> , index : number) : void => { +vector.forEach((value : number, index ?: number) : void => { console.log("value:" + value, "index:" + index); }); ``` @@ -864,7 +864,7 @@ for (let item of nums) { // 使用方法二: let iter = vector[Symbol.iterator](); -let temp = iter.next().value; +let temp: IteratorResult = iter.next().value; while(temp != undefined) { console.log("value:" + temp); temp = iter.next().value;