From cb9e359a51c3249d8f5157db69d43fd413ddeda6 Mon Sep 17 00:00:00 2001 From: Florian Merz Date: Thu, 11 Feb 2021 14:45:12 +0100 Subject: unslug ca: move --- .../reference/global_objects/array/keys/index.html | 115 +++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 files/ca/web/javascript/reference/global_objects/array/keys/index.html (limited to 'files/ca/web/javascript/reference/global_objects/array/keys') diff --git a/files/ca/web/javascript/reference/global_objects/array/keys/index.html b/files/ca/web/javascript/reference/global_objects/array/keys/index.html new file mode 100644 index 0000000000..7d9df8e1f5 --- /dev/null +++ b/files/ca/web/javascript/reference/global_objects/array/keys/index.html @@ -0,0 +1,115 @@ +--- +title: Array.prototype.keys() +slug: Web/JavaScript/Referencia/Objectes_globals/Array/keys +translation_of: Web/JavaScript/Reference/Global_Objects/Array/keys +--- +
{{JSRef}}
+ +

El mètode keys() retorna un nou Array Iterator que conté la clau de cada posició d'un array.

+ +

Sintaxi

+ +
arr.keys()
+ +

Exemples

+ +

Ús bàsic

+ +
var arr = ["a", "b", "c"];
+var iterator = arr.keys();
+
+console.log(iterator.next()); // { value: 0, done: false }
+console.log(iterator.next()); // { value: 1, done: false }
+console.log(iterator.next()); // { value: 2, done: false }
+console.log(iterator.next()); // { value: undefined, done: true }
+
+ +

L'iterador de claus no ignora els forats

+ +
var arr = ["a", , "c"];
+var sparseKeys = Object.keys(arr);
+var denseKeys = [...arr.keys()];
+console.log(sparseKeys); // ['0', '2']
+console.log(denseKeys);  // [0, 1, 2]
+
+ +

Especificacions

+ + + + + + + + + + + + + + + + + + + +
EspecificacióEstatComentaris
{{SpecName('ES6', '#sec-array.prototype.keys', 'Array.prototype.keys')}}{{Spec2('ES6')}}Definició inicial.
{{SpecName('ESDraft', '#sec-array.prototype.keys', 'Array.prototype.keys')}}{{Spec2('ESDraft')}} 
+ +

Compatibilitat amb navegadors

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + +
CaracterísticaChromeFirefox (Gecko)Internet ExplorerOperaSafari
Suport bàsic{{CompatChrome("38")}}{{CompatGeckoDesktop("28")}}{{CompatNo}}{{CompatOpera("25")}}{{CompatSafari("7.1")}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
CaracterísticaAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Suport bàsic{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("28")}}{{CompatNo}}{{CompatNo}}8.0
+
+ +

Vegeu també

+ + -- cgit v1.2.3-54-g00ecf