source
stringlengths
14
113
code
stringlengths
10
21.3k
application-dev\reference\apis-arkts\js-apis-fastbuffer.md
import { fastbuffer } from '@kit.ArkTS'; let buf = fastbuffer.allocUninitializedFromPool(6); let result = buf.writeUIntLE(0x1234567890ab, 0, 6); console.info("result = " + result); // Output: result = 6
application-dev\reference\apis-arkts\js-apis-hashmap.md
import { HashMap } from '@kit.ArkTS';
application-dev\reference\apis-arkts\js-apis-hashmap.md
let hashMap: HashMap<string, number> = new HashMap();
application-dev\reference\apis-arkts\js-apis-hashmap.md
const hashMap: HashMap<string, number> = new HashMap(); let result = hashMap.isEmpty();
application-dev\reference\apis-arkts\js-apis-hashmap.md
const hashMap: HashMap<string, number> = new HashMap(); hashMap.set("squirrel", 123); let result = hashMap.hasKey("squirrel");
application-dev\reference\apis-arkts\js-apis-hashmap.md
const hashMap: HashMap<string, number> = new HashMap(); hashMap.set("squirrel", 123); let result = hashMap.hasValue(123);
application-dev\reference\apis-arkts\js-apis-hashmap.md
const hashMap: HashMap<string, number> = new HashMap(); hashMap.set("squirrel", 123); hashMap.set("sparrow", 356); let result = hashMap.get("sparrow");
application-dev\reference\apis-arkts\js-apis-hashmap.md
const hashMap: HashMap<string, number> = new HashMap(); hashMap.set("squirrel", 123); hashMap.set("sparrow", 356); let newHashMap: HashMap<string, number> = new HashMap(); newHashMap.set("newMap", 99); hashMap.setAll(newHashMap);
application-dev\reference\apis-arkts\js-apis-hashmap.md
let hashMap: HashMap<string, number> = new HashMap(); let result = hashMap.set("squirrel", 123);
application-dev\reference\apis-arkts\js-apis-hashmap.md
let hashMap: HashMap<string, number> = new HashMap(); hashMap.set("squirrel", 123); hashMap.set("sparrow", 356); let result = hashMap.remove("sparrow");
application-dev\reference\apis-arkts\js-apis-hashmap.md
let hashMap: HashMap<string, number> = new HashMap(); hashMap.set("squirrel", 123); hashMap.set("sparrow", 356); hashMap.clear();
application-dev\reference\apis-arkts\js-apis-hashmap.md
let hashMap: HashMap<string, number> = new HashMap(); hashMap.set("squirrel", 123); hashMap.set("sparrow", 356); let iter = hashMap.keys(); let temp: IteratorResult<string,number> = iter.next(); while(!temp.done) { console.log("value:" + temp.value); temp = iter.next(); }
application-dev\reference\apis-arkts\js-apis-hashmap.md
let hashMap: HashMap<string, number> = new HashMap(); hashMap.set("squirrel", 123); hashMap.set("sparrow", 356); let iter = hashMap.values(); let temp: IteratorResult<number> = iter.next(); while(!temp.done) { console.log("value:" + temp.value); temp = iter.next(); }
application-dev\reference\apis-arkts\js-apis-hashmap.md
let hashMap: HashMap<string, number> = new HashMap(); hashMap.set("sparrow", 123); let result = hashMap.replace("sparrow", 357);
application-dev\reference\apis-arkts\js-apis-hashmap.md
let hashMap: HashMap<string, number> = new HashMap(); hashMap.set("sparrow", 123); hashMap.set("gull", 357); hashMap.forEach((value?: number, key?: string) => { console.log("value:" + value, "key:" + key); });
application-dev\reference\apis-arkts\js-apis-hashmap.md
// You are not advised to use the set or remove APIs in forEach because they may cause unpredictable risks such as infinite loops. You can use the for loop when inserting or deleting data. let hashMap: HashMap<string, number> = new HashMap(); for(let i = 0; i < 10; i++) { hashMap.set("sparrow" + i, 123); } for(let i...
application-dev\reference\apis-arkts\js-apis-hashmap.md
let hashMap: HashMap<string, number> = new HashMap(); hashMap.set("squirrel", 123); hashMap.set("sparrow", 356); let iter = hashMap.entries(); let temp: IteratorResult<Object[]> = iter.next(); while(!temp.done) { console.log("key:" + temp.value[0]); console.log("value:" + temp.value[1]); temp = iter.next(); }
application-dev\reference\apis-arkts\js-apis-hashmap.md
// You are not advised to use the set or remove APIs in entries because they may cause unpredictable risks such as infinite loops. You can use the for loop when inserting or deleting data. let hashMap: HashMap<string, number> = new HashMap(); for(let i = 0; i < 10; i++) { hashMap.set("sparrow" + i, 123); } for(let i...
application-dev\reference\apis-arkts\js-apis-hashmap.md
let hashMap: HashMap<string, number> = new HashMap(); hashMap.set("squirrel", 123); hashMap.set("sparrow", 356); // Method 1: let keys = Array.from(hashMap.keys()); for (let key of keys) { console.log("key:" + key); console.log("value:" + hashMap.get(key)); } // Method 2: let iter = hashMap[Symbol.iterator](); ...
application-dev\reference\apis-arkts\js-apis-hashmap.md
// You are not advised to use the set or remove APIs in Symbol.iterator because they may cause unpredictable risks such as infinite loops. You can use the for loop when inserting or deleting data. let hashMap: HashMap<string, number> = new HashMap(); for(let i = 0; i < 10; i++) { hashMap.set("sparrow" + i, 123); } f...
application-dev\reference\apis-arkts\js-apis-hashset.md
import { HashSet } from '@kit.ArkTS';
application-dev\reference\apis-arkts\js-apis-hashset.md
let hashSet: HashSet<number> = new HashSet(); hashSet.add(1); hashSet.add(2); hashSet.add(3); hashSet.add(4); hashSet.add(5); let res = hashSet.length;
application-dev\reference\apis-arkts\js-apis-hashset.md
let hashSet: HashSet<number> = new HashSet();
application-dev\reference\apis-arkts\js-apis-hashset.md
const hashSet: HashSet<number> = new HashSet(); let result = hashSet.isEmpty();
application-dev\reference\apis-arkts\js-apis-hashset.md
let hashSet: HashSet<string> = new HashSet(); hashSet.add("squirrel"); let result = hashSet.has("squirrel");
application-dev\reference\apis-arkts\js-apis-hashset.md
let hashSet: HashSet<string> = new HashSet(); let result = hashSet.add("squirrel");
application-dev\reference\apis-arkts\js-apis-hashset.md
let hashSet: HashSet<string> = new HashSet(); hashSet.add("squirrel"); hashSet.add("sparrow"); let result = hashSet.remove("sparrow");
application-dev\reference\apis-arkts\js-apis-hashset.md
let hashSet: HashSet<string> = new HashSet(); hashSet.add("squirrel"); hashSet.add("sparrow"); hashSet.clear();
application-dev\reference\apis-arkts\js-apis-hashset.md
let hashSet: HashSet<string> = new HashSet(); hashSet.add("squirrel"); hashSet.add("sparrow"); let iter = hashSet.values(); let temp = iter.next(); while(!temp.done) { console.log("value:" + temp.value); temp = iter.next(); }
application-dev\reference\apis-arkts\js-apis-hashset.md
let hashSet: HashSet<string> = new HashSet(); hashSet.add("sparrow"); hashSet.add("squirrel"); hashSet.forEach((value?: string, key?: string): void => { console.log("value:" + value, "key:" + key); });
application-dev\reference\apis-arkts\js-apis-hashset.md
// You are not advised to use the set or remove APIs in forEach because they may cause unpredictable risks such as infinite loops. You can use the for loop when inserting or deleting data. let hashSet : HashSet<string> = new HashSet(); for(let i = 0;i < 10; i++) { hashSet.add("sparrow" + i); } for(let i = 0;i < 10; i...
application-dev\reference\apis-arkts\js-apis-hashset.md
let hashSet: HashSet<string> = new HashSet(); hashSet.add("squirrel"); hashSet.add("sparrow"); let iter = hashSet.entries(); let temp: IteratorResult<[string, string]> = iter.next(); while(!temp.done) { console.log("key:" + temp.value[0]); console.log("value:" + temp.value[1]); temp = iter.next(); }
application-dev\reference\apis-arkts\js-apis-hashset.md
// You are not advised to use the set or remove APIs in entries because they may cause unpredictable risks such as infinite loops. You can use the for loop when inserting or deleting data. let hashSet : HashSet<string> = new HashSet(); for(let i = 0;i < 10; i++) { hashSet.add("sparrow" + i); } for(let i = 0;i < 10; i...
application-dev\reference\apis-arkts\js-apis-hashset.md
let hashSet: HashSet<string> = new HashSet(); hashSet.add("squirrel"); hashSet.add("sparrow"); // Method 1: let val: Array<string> = Array.from(hashSet.values()); for (let item of val) { console.log("value: " + item); } // Method 2: let iter = hashSet[Symbol.iterator](); let temp: IteratorResult<string> = iter.next...
application-dev\reference\apis-arkts\js-apis-hashset.md
// You are not advised to use the set or remove APIs in Symbol.iterator because they may cause unpredictable risks such as infinite loops. You can use the for loop when inserting or deleting data. let hashSet : HashSet<string> = new HashSet(); for(let i = 0;i < 10;i++) { hashSet.add("sparrow" + i); } for(let i = 0;i ...
application-dev\reference\apis-arkts\js-apis-json.md
import { JSON } from '@kit.ArkTS';
application-dev\reference\apis-arkts\js-apis-json.md
// /entry/src/main/ets/pages/test.ts export function reviverFunc(key, value) { if (key === "age") { return value + 1; } return value; }
application-dev\reference\apis-arkts\js-apis-json.md
import { JSON } from '@kit.ArkTS'; import { reviverFunc } from './test'; let jsonText = '{"name": "John", "age": 30, "city": "ChongQing"}'; let obj = JSON.parse(jsonText); console.info((obj as object)?.["name"]); // Output: John const jsonTextStr = '{"name": "John", "age": 30}'; let objRst = JSON.parse(jsonTextStr, re...
application-dev\reference\apis-arkts\js-apis-json.md
import { JSON } from '@kit.ArkTS'; /* * Deserialize JSON strings with nested quotation marks. * */ interface Info { name: string; age: number; } interface TestObj { info: Info; } interface TestStr { info: string; } // The JSON string contains nested quotation marks. This breaks the JSON structure, making...
application-dev\reference\apis-arkts\js-apis-json.md
// /entry/src/main/ets/pages/test.ts export let exportObj = {1: "John", 2: 30, 3: "New York"};
application-dev\reference\apis-arkts\js-apis-json.md
import { JSON } from '@kit.ArkTS'; import { exportObj } from './test'; let arr = [1, 2]; let rstArrStr = JSON.stringify(exportObj, arr); console.info(rstArrStr); // Output: "{"1":"John,""2":30}" interface Person { name: string; age: number; city: string; } let inputObj = {"name": "John", "age": 30, "city": "Chon...
application-dev\reference\apis-arkts\js-apis-json.md
// /entry/src/main/ets/pages/test.ts export function replacer(key: string, value: Object): Object { if (typeof value === "string") { return value.toUpperCase(); } return value; }
application-dev\reference\apis-arkts\js-apis-json.md
import { JSON } from '@kit.ArkTS'; import { replacer } from './test'; interface Person { name: string; age: number; city: string; } let inputObj = {"name": "John", "age": 30, "city": "ChongQing"} as Person; let rstStr= JSON.stringify(inputObj, replacer); console.info(rstStr); // Output: "{"name":"JOHN,""age":30,...
application-dev\reference\apis-arkts\js-apis-json.md
import { JSON } from '@kit.ArkTS'; /* * Serialize BigInt objects. * */ let bigIntObject = BigInt(112233445566778899) /* * Scenario 1: Serialize a BigInt object without a custom conversion function. * */ console.info(JSON.stringify(bigIntObject)); // 112233445566778896 /* * Scenario 2: Use a custom conversion fu...
application-dev\reference\apis-arkts\js-apis-json.md
import { JSON } from '@kit.ArkTS'; /* * Serialize floating-point numbers. * */ let floatNumber1 = 10.12345; let floatNumber2 = 10.00; // Serializing a floating-point number with a non-zero fractional part works as expected. let result1 = JSON.stringify(floatNumber1); console.info(result1); // 10.12345 // Serializi...
application-dev\reference\apis-arkts\js-apis-json.md
import { JSON } from '@kit.ArkTS'; const jsonText = '{"name": "John", "age": 30, "city": "ChongQing"}'; let inputObj = JSON.parse(jsonText); let result = JSON.has(inputObj, "name"); console.info("result = " + result); // Output: result = true
application-dev\reference\apis-arkts\js-apis-json.md
import { JSON } from '@kit.ArkTS'; const jsonText = '{"name": "John", "age": 30, "city": "ChongQing"}'; let inputObj = JSON.parse(jsonText); JSON.remove(inputObj, "name"); let result = JSON.has(inputObj, "name"); console.info("result = " + result); // Output: result = false
application-dev\reference\apis-arkts\js-apis-lightweightmap.md
import { LightWeightMap } from '@kit.ArkTS';
application-dev\reference\apis-arkts\js-apis-lightweightmap.md
let lightWeightMap: LightWeightMap<string, number> = new LightWeightMap();
application-dev\reference\apis-arkts\js-apis-lightweightmap.md
const lightWeightMap: LightWeightMap<string, number> = new LightWeightMap(); let result = lightWeightMap.isEmpty();
application-dev\reference\apis-arkts\js-apis-lightweightmap.md
let lightWeightMap: LightWeightMap<string, number> = new LightWeightMap(); lightWeightMap.set("squirrel", 123); lightWeightMap.set("sparrow", 356); let map: LightWeightMap<string, number> = new LightWeightMap(); map.set("sparrow", 356); let result = lightWeightMap.hasAll(map);
application-dev\reference\apis-arkts\js-apis-lightweightmap.md
let lightWeightMap: LightWeightMap<string, number> = new LightWeightMap(); lightWeightMap.set("squirrel", 123); let result = lightWeightMap.hasKey("squirrel");
application-dev\reference\apis-arkts\js-apis-lightweightmap.md
let lightWeightMap: LightWeightMap<string, number> = new LightWeightMap(); lightWeightMap.set("squirrel", 123); let result = lightWeightMap.hasValue(123);
application-dev\reference\apis-arkts\js-apis-lightweightmap.md
let lightWeightMap: LightWeightMap<string, number> = new LightWeightMap(); lightWeightMap.increaseCapacityTo(10);
application-dev\reference\apis-arkts\js-apis-lightweightmap.md
let lightWeightMap: LightWeightMap<string, number> = new LightWeightMap(); lightWeightMap.set("squirrel", 123); lightWeightMap.set("sparrow", 356); let result = lightWeightMap.get("sparrow");
application-dev\reference\apis-arkts\js-apis-lightweightmap.md
let lightWeightMap: LightWeightMap<string, number> = new LightWeightMap(); lightWeightMap.set("squirrel", 123); lightWeightMap.set("sparrow", 356); let result = lightWeightMap.getIndexOfKey("sparrow");
application-dev\reference\apis-arkts\js-apis-lightweightmap.md
let lightWeightMap: LightWeightMap<string, number> = new LightWeightMap(); lightWeightMap.set("squirrel", 123); lightWeightMap.set("sparrow", 356); let result = lightWeightMap.getIndexOfValue(123);
application-dev\reference\apis-arkts\js-apis-lightweightmap.md
let lightWeightMap: LightWeightMap<string, number> = new LightWeightMap(); lightWeightMap.set("squirrel", 123); lightWeightMap.set("sparrow", 356); let result = lightWeightMap.getKeyAt(1);
application-dev\reference\apis-arkts\js-apis-lightweightmap.md
let lightWeightMap: LightWeightMap<string, number> = new LightWeightMap(); lightWeightMap.set("squirrel", 123); lightWeightMap.set("sparrow", 356); let map: LightWeightMap<string, number> = new LightWeightMap(); map.setAll(lightWeightMap); // Add all elements in lightWeightMap to the map.
application-dev\reference\apis-arkts\js-apis-lightweightmap.md
let lightWeightMap: LightWeightMap<string, number> = new LightWeightMap(); let result = lightWeightMap.set("squirrel", 123);
application-dev\reference\apis-arkts\js-apis-lightweightmap.md
let lightWeightMap: LightWeightMap<string, number> = new LightWeightMap(); lightWeightMap.set("squirrel", 123); lightWeightMap.set("sparrow", 356); lightWeightMap.remove("sparrow");
application-dev\reference\apis-arkts\js-apis-lightweightmap.md
let lightWeightMap: LightWeightMap<string, number> = new LightWeightMap(); lightWeightMap.set("squirrel", 123); lightWeightMap.set("sparrow", 356); let result = lightWeightMap.removeAt(1);
application-dev\reference\apis-arkts\js-apis-lightweightmap.md
let lightWeightMap: LightWeightMap<string, number> = new LightWeightMap(); lightWeightMap.set("squirrel", 123); lightWeightMap.set("sparrow", 356); lightWeightMap.setValueAt(1, 3546);
application-dev\reference\apis-arkts\js-apis-lightweightmap.md
let lightWeightMap: LightWeightMap<string, number> = new LightWeightMap(); lightWeightMap.set("squirrel", 123); lightWeightMap.set("sparrow", 356); let result = lightWeightMap.getValueAt(1);
application-dev\reference\apis-arkts\js-apis-lightweightmap.md
let lightWeightMap: LightWeightMap<string, number> = new LightWeightMap(); lightWeightMap.set("squirrel", 123); lightWeightMap.set("sparrow", 356); lightWeightMap.clear();
application-dev\reference\apis-arkts\js-apis-lightweightmap.md
let lightWeightMap: LightWeightMap<string, number> = new LightWeightMap(); lightWeightMap.set("squirrel", 123); lightWeightMap.set("sparrow", 356); let iter = lightWeightMap.keys(); let temp: IteratorResult<string, number> = iter.next(); while(!temp.done) { console.log("value:" + temp.value); temp = iter.next(); }
application-dev\reference\apis-arkts\js-apis-lightweightmap.md
let lightWeightMap: LightWeightMap<string, number> = new LightWeightMap(); lightWeightMap.set("squirrel", 123); lightWeightMap.set("sparrow", 356); let iter = lightWeightMap.values(); let temp: IteratorResult<number> = iter.next(); while(!temp.done) { console.log("value:" + temp.value); temp = iter.next(); }
application-dev\reference\apis-arkts\js-apis-lightweightmap.md
let lightWeightMap: LightWeightMap<string, number> = new LightWeightMap(); lightWeightMap.set("sparrow", 123); lightWeightMap.set("gull", 357); lightWeightMap.forEach((value?: number, key?: string) => { console.log("value:" + value, "key:" + key); });
application-dev\reference\apis-arkts\js-apis-lightweightmap.md
// You are not advised to use the set, setValueAt, remove, or removeAt APIs in forEach because they may cause unpredictable risks such as infinite loops. You can use the for loop when inserting or deleting data. let lightWeightMap: LightWeightMap<string, number> = new LightWeightMap(); for(let i = 0; i < 10; i++) { l...
application-dev\reference\apis-arkts\js-apis-lightweightmap.md
let lightWeightMap: LightWeightMap<string, number> = new LightWeightMap(); lightWeightMap.set("squirrel", 123); lightWeightMap.set("sparrow", 356); let iter = lightWeightMap.entries(); let temp: IteratorResult<Object[]> = iter.next(); while(!temp.done) { console.log("key:" + temp.value[0]); console.log("value:" + t...
application-dev\reference\apis-arkts\js-apis-lightweightmap.md
// You are not advised to use the set, setValueAt, remove, or removeAt APIs in entries because they may cause unpredictable risks such as infinite loops. You can use the for loop when inserting or deleting data. let lightWeightMap: LightWeightMap<string, number> = new LightWeightMap(); for(let i = 0; i < 10; i++) { l...
application-dev\reference\apis-arkts\js-apis-lightweightmap.md
let lightWeightMap: LightWeightMap<string, number> = new LightWeightMap(); lightWeightMap.set("squirrel", 123); lightWeightMap.set("sparrow", 356); let result = lightWeightMap.toString();
application-dev\reference\apis-arkts\js-apis-lightweightmap.md
let lightWeightMap: LightWeightMap<string, number> = new LightWeightMap(); lightWeightMap.set("squirrel", 123); lightWeightMap.set("sparrow", 356); // Method 1: let nums = Array.from(lightWeightMap.values()); for (let item1 of nums) { console.log("value:" + item1); } let key = Array.from(lightWeightMap.keys()); for...
application-dev\reference\apis-arkts\js-apis-lightweightmap.md
// You are not advised to use the set, setValueAt, remove, or removeAt APIs in Symbol.iterator because they may cause unpredictable risks such as infinite loops. You can use the for loop when inserting or deleting data. let lightWeightMap: LightWeightMap<string, number> = new LightWeightMap(); for(let i = 0; i < 10; i+...
application-dev\reference\apis-arkts\js-apis-lightweightset.md
import { LightWeightSet } from '@kit.ArkTS';
application-dev\reference\apis-arkts\js-apis-lightweightset.md
let lightWeightSet: LightWeightSet<number | string> = new LightWeightSet();
application-dev\reference\apis-arkts\js-apis-lightweightset.md
const lightWeightSet: LightWeightSet<number> = new LightWeightSet(); let result = lightWeightSet.isEmpty();
application-dev\reference\apis-arkts\js-apis-lightweightset.md
let lightWeightSet: LightWeightSet<string> = new LightWeightSet(); let result = lightWeightSet.add("squirrel");
application-dev\reference\apis-arkts\js-apis-lightweightset.md
let lightWeightSet: LightWeightSet<string> = new LightWeightSet(); lightWeightSet.add("squirrel"); lightWeightSet.add("sparrow"); let set: LightWeightSet<string> = new LightWeightSet(); set.add("gull"); let result = lightWeightSet.addAll(set);
application-dev\reference\apis-arkts\js-apis-lightweightset.md
let lightWeightSet: LightWeightSet<string> = new LightWeightSet(); lightWeightSet.add("squirrel"); lightWeightSet.add("sparrow"); let set: LightWeightSet<string> = new LightWeightSet(); set.add("sparrow"); let result = lightWeightSet.hasAll(set);
application-dev\reference\apis-arkts\js-apis-lightweightset.md
let lightWeightSet: LightWeightSet<number> = new LightWeightSet(); lightWeightSet.add(123); let result = lightWeightSet.has(123);
application-dev\reference\apis-arkts\js-apis-lightweightset.md
let lightWeightSet: LightWeightSet<string> = new LightWeightSet(); lightWeightSet.increaseCapacityTo(10);
application-dev\reference\apis-arkts\js-apis-lightweightset.md
let lightWeightSet: LightWeightSet<string> = new LightWeightSet(); lightWeightSet.add("squirrel"); lightWeightSet.add("sparrow"); let result = lightWeightSet.getIndexOf("sparrow");
application-dev\reference\apis-arkts\js-apis-lightweightset.md
let lightWeightSet: LightWeightSet<string> = new LightWeightSet(); lightWeightSet.add("squirrel"); lightWeightSet.add("sparrow"); let result = lightWeightSet.remove("sparrow");
application-dev\reference\apis-arkts\js-apis-lightweightset.md
let lightWeightSet: LightWeightSet<string> = new LightWeightSet(); lightWeightSet.add("squirrel"); lightWeightSet.add("sparrow"); let result = lightWeightSet.removeAt(1);
application-dev\reference\apis-arkts\js-apis-lightweightset.md
let lightWeightSet: LightWeightSet<string> = new LightWeightSet(); lightWeightSet.add("squirrel"); lightWeightSet.add("sparrow"); let result = lightWeightSet.getValueAt(1);
application-dev\reference\apis-arkts\js-apis-lightweightset.md
let lightWeightSet: LightWeightSet<string> = new LightWeightSet(); lightWeightSet.add("squirrel"); lightWeightSet.add("sparrow"); lightWeightSet.clear();
application-dev\reference\apis-arkts\js-apis-lightweightset.md
let lightWeightSet: LightWeightSet<string> = new LightWeightSet(); lightWeightSet.add("squirrel"); lightWeightSet.add("sparrow"); let result = lightWeightSet.toString();
application-dev\reference\apis-arkts\js-apis-lightweightset.md
let lightWeightSet: LightWeightSet<string> = new LightWeightSet(); lightWeightSet.add("squirrel"); lightWeightSet.add("sparrow"); let result = lightWeightSet.toArray();
application-dev\reference\apis-arkts\js-apis-lightweightset.md
let lightWeightSet: LightWeightSet<string> = new LightWeightSet(); lightWeightSet.add("squirrel"); lightWeightSet.add("sparrow"); let iter = lightWeightSet.values(); let index = 0; while(index < lightWeightSet.length) { console.log(JSON.stringify(iter.next().value)); index++; }
application-dev\reference\apis-arkts\js-apis-lightweightset.md
let lightWeightSet: LightWeightSet<string> = new LightWeightSet(); lightWeightSet.add("sparrow"); lightWeightSet.add("gull"); lightWeightSet.forEach((value ?: string, key ?: string) => { console.log("value:" + value, "key:" + key); });
application-dev\reference\apis-arkts\js-apis-lightweightset.md
// You are not advised to use the add, remove, or removeAt APIs in forEach because they may cause unpredictable risks such as infinite loops. You can use the for loop when inserting or deleting data. let lightWeightSet: LightWeightSet<string> = new LightWeightSet(); for(let i = 0; i < 10; i++) { lightWeightSet.add(i ...
application-dev\reference\apis-arkts\js-apis-lightweightset.md
let lightWeightSet: LightWeightSet<string> = new LightWeightSet(); lightWeightSet.add("squirrel"); lightWeightSet.add("sparrow"); let iter = lightWeightSet.entries(); let index = 0; while(index < lightWeightSet.length) { console.log(JSON.stringify(iter.next().value)); index++; }
application-dev\reference\apis-arkts\js-apis-lightweightset.md
// You are not advised to use the add, remove, or removeAt APIs in entries because they may cause unpredictable risks such as infinite loops. You can use the for loop when inserting or deleting data. let lightWeightSet: LightWeightSet<string> = new LightWeightSet(); for(let i = 0; i < 10; i++) { lightWeightSet.add(i ...
application-dev\reference\apis-arkts\js-apis-lightweightset.md
let lightWeightSet: LightWeightSet<string> = new LightWeightSet(); lightWeightSet.add("squirrel"); lightWeightSet.add("sparrow"); // Method 1: let nums: Array<string> = lightWeightSet.toArray() for (let item of nums) { console.log("value:" + item); } // Method 2: let iter = lightWeightSet[Symbol.iterator](); let te...
application-dev\reference\apis-arkts\js-apis-lightweightset.md
// You are not advised to use the add, remove, or removeAt APIs in Symbol.iterator because they may cause unpredictable risks such as infinite loops. You can use the for loop when inserting or deleting data. let lightWeightSet: LightWeightSet<string> = new LightWeightSet(); for(let i = 0; i < 10; i++) { lightWeightSe...
application-dev\reference\apis-arkts\js-apis-lightweightset.md
let lightWeightSet: LightWeightSet<string> = new LightWeightSet(); lightWeightSet.add("squirrel"); lightWeightSet.add("sparrow"); let obj = ["sparrow", "squirrel"]; let result = lightWeightSet.equal(obj);
application-dev\reference\apis-arkts\js-apis-linkedlist.md
import { LinkedList } from '@kit.ArkTS';
application-dev\reference\apis-arkts\js-apis-linkedlist.md
let linkedList: LinkedList<string | number | boolean | object> = new LinkedList();
application-dev\reference\apis-arkts\js-apis-linkedlist.md
let linkedList: LinkedList<string | number | boolean | object> = new LinkedList(); let result = linkedList.add("a"); let result1 = linkedList.add(1); let b = [1, 2, 3]; let result2 = linkedList.add(b); class C { name: string = '' age: string = '' } let c: C = {name : "Dylan", age : "13"}; let result3 = linkedList.a...