From 95aca4b4d8fa62815d4bd412fff1a364f842814a Mon Sep 17 00:00:00 2001 From: Ryan Johnson Date: Thu, 29 Apr 2021 16:16:42 -0700 Subject: remove retired locales (#699) --- .../global_objects/array/concat/index.html | 167 ---------- .../global_objects/array/entries/index.html | 129 ------- .../global_objects/array/every/index.html | 189 ----------- .../global_objects/array/filter/index.html | 243 -------------- .../reference/global_objects/array/find/index.html | 205 ------------ .../global_objects/array/findindex/index.html | 177 ---------- .../global_objects/array/foreach/index.html | 308 ----------------- .../reference/global_objects/array/from/index.html | 258 -------------- .../global_objects/array/includes/index.html | 176 ---------- .../reference/global_objects/array/index.html | 371 --------------------- .../global_objects/array/indexof/index.html | 246 -------------- .../global_objects/array/isarray/index.html | 154 --------- .../reference/global_objects/array/join/index.html | 107 ------ .../global_objects/array/length/index.html | 145 -------- .../reference/global_objects/array/map/index.html | 307 ----------------- .../reference/global_objects/array/of/index.html | 98 ------ .../reference/global_objects/array/pop/index.html | 117 ------- .../reference/global_objects/array/push/index.html | 152 --------- .../global_objects/array/reverse/index.html | 107 ------ .../global_objects/array/shift/index.html | 112 ------- .../reference/global_objects/array/sort/index.html | 251 -------------- .../global_objects/array/splice/index.html | 149 --------- .../global_objects/array/unshift/index.html | 114 ------- .../global_objects/array/values/index.html | 86 ----- 24 files changed, 4368 deletions(-) delete mode 100644 files/tr/web/javascript/reference/global_objects/array/concat/index.html delete mode 100644 files/tr/web/javascript/reference/global_objects/array/entries/index.html delete mode 100644 files/tr/web/javascript/reference/global_objects/array/every/index.html delete mode 100644 files/tr/web/javascript/reference/global_objects/array/filter/index.html delete mode 100644 files/tr/web/javascript/reference/global_objects/array/find/index.html delete mode 100644 files/tr/web/javascript/reference/global_objects/array/findindex/index.html delete mode 100644 files/tr/web/javascript/reference/global_objects/array/foreach/index.html delete mode 100644 files/tr/web/javascript/reference/global_objects/array/from/index.html delete mode 100644 files/tr/web/javascript/reference/global_objects/array/includes/index.html delete mode 100644 files/tr/web/javascript/reference/global_objects/array/index.html delete mode 100644 files/tr/web/javascript/reference/global_objects/array/indexof/index.html delete mode 100644 files/tr/web/javascript/reference/global_objects/array/isarray/index.html delete mode 100644 files/tr/web/javascript/reference/global_objects/array/join/index.html delete mode 100644 files/tr/web/javascript/reference/global_objects/array/length/index.html delete mode 100644 files/tr/web/javascript/reference/global_objects/array/map/index.html delete mode 100644 files/tr/web/javascript/reference/global_objects/array/of/index.html delete mode 100644 files/tr/web/javascript/reference/global_objects/array/pop/index.html delete mode 100644 files/tr/web/javascript/reference/global_objects/array/push/index.html delete mode 100644 files/tr/web/javascript/reference/global_objects/array/reverse/index.html delete mode 100644 files/tr/web/javascript/reference/global_objects/array/shift/index.html delete mode 100644 files/tr/web/javascript/reference/global_objects/array/sort/index.html delete mode 100644 files/tr/web/javascript/reference/global_objects/array/splice/index.html delete mode 100644 files/tr/web/javascript/reference/global_objects/array/unshift/index.html delete mode 100644 files/tr/web/javascript/reference/global_objects/array/values/index.html (limited to 'files/tr/web/javascript/reference/global_objects/array') diff --git a/files/tr/web/javascript/reference/global_objects/array/concat/index.html b/files/tr/web/javascript/reference/global_objects/array/concat/index.html deleted file mode 100644 index dbeaff447e..0000000000 --- a/files/tr/web/javascript/reference/global_objects/array/concat/index.html +++ /dev/null @@ -1,167 +0,0 @@ ---- -title: Array.prototype.concat -slug: Web/JavaScript/Reference/Global_Objects/Array/concat -tags: - - Array - - JavaScript - - Method - - Prototype -translation_of: Web/JavaScript/Reference/Global_Objects/Array/concat ---- -
{{JSRef("Global_Objects", "Array")}}
- -

Özet

- -

concat() metodu eklendigi dizi ile parametre olarak aldığı dizi(leri) birleştirerek yeni bir dizi döndürür.

- -

Söz Dizimi

- -
var new_array = old_array.concat(value1[, value2[, ...[, valueN]]])
- -

Parmetreler

- -
-
valueN
-
Yeni diziye eklenecek dizi ve/veya değerler. Detaylar için aşağıdaki açıklamayı okuyunuz.
-
- -

Açıklama

- -

concat çağırılan nesnelerin elemanlarını içeren yeni bir dizi oluşturur. Çağırılma sırasıyla, diziyse elemanlarını, değerse kendisini ekler.

- -

concat , this veya çağırılan dizilerden herhangi birini değiştirmez. Onları kopyalayarak yeni bir dizi oluşturur. Orjinal dizilerin öğeleri yeni diziye aşağıdaki gibi kopyalanır:

- - - -
-

Not: Dizi/değerlerin birleştirilmesi orjinallerini değiştirmez. Ayrıca, yeni dizi (eleman nesne referansı değilse) üzerindeki herhangi bir operasyon orjinal dizileri etkilemez. Tam tersi de geçerlidir.

-
- -

Örnekler

- -

Örnek: İki diziyi birleştirme

- -

Aşağıdaki kod iki diziyi birleştiriyor:

- -
var alpha = ['a', 'b', 'c'],
-    numeric = [1, 2, 3];
-
-var alphaNumeric = alpha.concat(numeric);
-
-console.log(alphaNumeric); // Result: ['a', 'b', 'c', 1, 2, 3]
-
- -

Örnek: Üç diziyi birleştirme

- -

Aşağıdaki kod üç diziyi birleştiriyor:

- -
var num1 = [1, 2, 3],
-    num2 = [4, 5, 6],
-    num3 = [7, 8, 9];
-
-var nums = num1.concat(num2, num3);
-
-console.log(nums); // Result: [1, 2, 3, 4, 5, 6, 7, 8, 9]
-
- -

Örnek: Değerleri dizi ile birleştirme

- -

Aşağıdaki kod değerler ile diziyi birleştiriyor:

- -
var alpha = ['a', 'b', 'c'];
-
-var alphaNumeric = alpha.concat(1, [2, 3]);
-
-console.log(alphaNumeric); // Result: ['a', 'b', 'c', 1, 2, 3]
-
- -

Özellikler

- - - - - - - - - - - - - - - - - - - - - - - - -
ÖzelliklerDurumYorumlar
ECMAScript 3rd EditionStandardInitial definition. Implemented in JavaScript 1.2.
{{SpecName('ES5.1', '#sec-15.4.4.4', 'Array.prototype.concat')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-array.prototype.concat', 'Array.prototype.concat')}}{{Spec2('ES6')}} 
- -

Tarayıcı Uyumluluğu

- -
{{CompatibilityTable}}
- -
- - - - - - - - - - - - - - - - - - - -
ÖzellikChromeFirefox (Gecko)Internet ExplorerOperaSafari
Temel destek{{CompatChrome("1.0")}}{{CompatGeckoDesktop("1.7")}}{{CompatIE("5.5")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
-
- -
- - - - - - - - - - - - - - - - - - - - - -
ÖzellikAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Temel destek{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
-
- -

Ayrıca Bakınız

- - diff --git a/files/tr/web/javascript/reference/global_objects/array/entries/index.html b/files/tr/web/javascript/reference/global_objects/array/entries/index.html deleted file mode 100644 index 7e2d7b6a82..0000000000 --- a/files/tr/web/javascript/reference/global_objects/array/entries/index.html +++ /dev/null @@ -1,129 +0,0 @@ ---- -title: Array.prototype.entries() -slug: Web/JavaScript/Reference/Global_Objects/Array/entries -tags: - - Dizi - - döngü - - gezinilebilir -translation_of: Web/JavaScript/Reference/Global_Objects/Array/entries ---- -
{{JSRef}}
- -

entries() metodu, içerisinde, her bir elemanı için anahtar/değer çifti içeren yeni bir Gezinilebilir Dizi nesnesi döndürür.

- -
var a = ['a', 'b', 'c'];
-var iterator = a.entries();
-
-console.log(iterator.next().value); // [0, 'a']
-console.log(iterator.next().value); // [1, 'b']
-console.log(iterator.next().value); // [2, 'c']
-
- -

Söz dizimi

- -
a.entries()
- -

Dönüş değeri

- -

Yeni bir gezinilebilir {{jsxref("Array")}} nesnesi.

- -

Örnekler

- -

Bir for…of döngüsü kullanımı

- -
var a = ['a', 'b', 'c'];
-var iterator = a.entries();
-
-for (let e of iterator) {
-  console.log(e);
-}
-// [0, 'a']
-// [1, 'b']
-// [2, 'c']
-
- -

Tanımlamalar

- - - - - - - - - - - - - - - - - - - -
TanımlamaDurumYorum
{{SpecName('ES2015', '#sec-array.prototype.entries', 'Array.prototype.entries')}}{{Spec2('ES2015')}}Initial definition.
{{SpecName('ESDraft', '#sec-array.prototype.entries', 'Array.prototype.entries')}}{{Spec2('ESDraft')}} 
- -

Tarayıcı uyumluluğu

- -
{{CompatibilityTable}}
- -
- - - - - - - - - - - - - - - - - - - -
ÖzellikChromeFirefox (Gecko)Internet ExplorerOperaSafari
Temel destekli{{CompatChrome("38")}}{{CompatGeckoDesktop("28")}}{{CompatNo}}{{CompatOpera("25")}}{{CompatSafari("7.1")}}
-
- -
- - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Temel destekli{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("28")}}{{CompatNo}}{{CompatNo}}8.0
-
- -

Ayrıca bknz.

- - diff --git a/files/tr/web/javascript/reference/global_objects/array/every/index.html b/files/tr/web/javascript/reference/global_objects/array/every/index.html deleted file mode 100644 index 1cab33d6fe..0000000000 --- a/files/tr/web/javascript/reference/global_objects/array/every/index.html +++ /dev/null @@ -1,189 +0,0 @@ ---- -title: Array.prototype.every() -slug: Web/JavaScript/Reference/Global_Objects/Array/every -translation_of: Web/JavaScript/Reference/Global_Objects/Array/every ---- -
{{JSRef}}
- -
every() metodu bir dizideki tüm elemanların verilen fonksiyonun testini geçip geçmediği kontrol eder. Bu metot true (doğru) yada false (yanlış) olarak ikilik değer döndürür. 
- -
-

Note: Test edilen array boş ise bu metot true deger döndürür.

-
- -
{{EmbedInteractiveExample("pages/js/array-every.html")}}
- - - -

Söz dizimi

- -
arr.every(callback(element[, index[, array]])[, thisArg])
- -

Parametreler

- -
-
callback
-
Her elemanı test eden üç değişken alan bir fonksiyon: -
-
element
-
İşlemde olan geçerli dizi elemanı.
-
index{{Optional_inline}}
-
İşlemde olan geçerli dizi elemanın indeksi .
-
array{{Optional_inline}}
-
every tarafından çağrılan dizi.
-
-
-
thisArg{{Optional_inline}}
-
Geri dönüş yapıldığında this olarak kullanıcak bir değer.
-
- -

Dönüş değeri

- -

Geri dönüş fonksiyonu her bir dizi elemanı için bir {{Glossary("truthy")}} deger dondürse true. Aksi takdirde, false.

- -

Description

- -

The every method executes the provided callback function once for each element present in the array until it finds the one where callback returns a {{Glossary("falsy")}} value. If such an element is found, the every method immediately returns false. Otherwise, if callback returns a {{Glossary("truthy")}} value for all elements, every returns true. callback is invoked only for indexes of the array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values.

- -

callback is invoked with three arguments: the value of the element, the index of the element, and the Array object being traversed.

- -

If a thisArg parameter is provided to every, it will be used as callback's this value. Otherwise, the value undefined will be used as its this value.  The this value ultimately observable by callback is determined according to the usual rules for determining the this seen by a function.

- -

every does not mutate the array on which it is called.

- -

The range of elements processed by every is set before the first invocation of callback. Therefore, callback will not run on elements that are appended to the array after the call to every begins. If existing elements of the array are changed, their value as passed to callback will be the value at the time every visits them. Elements that are deleted are not visited.

- -

every acts like the "for all" quantifier in mathematics. In particular, for an empty array, it returns true. (It is vacuously true that all elements of the empty set satisfy any given condition.)

- -

Örnekler

- -

Tüm dizi elemanlarının büyüklüğünün test edilmesi

- -

Aşağıdaki örnekte tüm dizi elemanlarının 10'dan büyük yada eşit olma durumu test edilir.

- -
function isBigEnough(element, index, array) {
-  return element >= 10;
-}
-[12, 5, 8, 130, 44].every(isBigEnough);   // false
-[12, 54, 18, 130, 44].every(isBigEnough); // true
-
- -

Ok fonksiyonlarını kullanma

- -

Ok fonksiyonları aynı testin daha kısa söz dizimi ile yapılmasını sağlar.

- -
[12, 5, 8, 130, 44].every(x => x >= 10); // false
-[12, 54, 18, 130, 44].every(x => x >= 10); // true
- -

Polyfill

- -

every was added to the ECMA-262 standard in the 5th edition, and it may not be present in other implementations of the standard. You can work around this by inserting the following code at the beginning of your scripts, allowing use of every in implementations which do not natively support it. This algorithm is exactly the one specified in ECMA-262, 5th edition, assuming Object and TypeError have their original values and that callbackfn.call evaluates to the original value of {{jsxref("Function.prototype.call")}}

- -
if (!Array.prototype.every) {
-  Array.prototype.every = function(callbackfn, thisArg) {
-    'use strict';
-    var T, k;
-
-    if (this == null) {
-      throw new TypeError('this is null or not defined');
-    }
-
-    // 1. Let O be the result of calling ToObject passing the this
-    //    value as the argument.
-    var O = Object(this);
-
-    // 2. Let lenValue be the result of calling the Get internal method
-    //    of O with the argument "length".
-    // 3. Let len be ToUint32(lenValue).
-    var len = O.length >>> 0;
-
-    // 4. If IsCallable(callbackfn) is false, throw a TypeError exception.
-    if (typeof callbackfn !== 'function') {
-      throw new TypeError();
-    }
-
-    // 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
-    if (arguments.length > 1) {
-      T = thisArg;
-    }
-
-    // 6. Let k be 0.
-    k = 0;
-
-    // 7. Repeat, while k < len
-    while (k < len) {
-
-      var kValue;
-
-      // a. Let Pk be ToString(k).
-      //   This is implicit for LHS operands of the in operator
-      // b. Let kPresent be the result of calling the HasProperty internal
-      //    method of O with argument Pk.
-      //   This step can be combined with c
-      // c. If kPresent is true, then
-      if (k in O) {
-
-        // i. Let kValue be the result of calling the Get internal method
-        //    of O with argument Pk.
-        kValue = O[k];
-
-        // ii. Let testResult be the result of calling the Call internal method
-        //     of callbackfn with T as the this value and argument list
-        //     containing kValue, k, and O.
-        var testResult = callbackfn.call(T, kValue, k, O);
-
-        // iii. If ToBoolean(testResult) is false, return false.
-        if (!testResult) {
-          return false;
-        }
-      }
-      k++;
-    }
-    return true;
-  };
-}
-
- -

Specifications

- - - - - - - - - - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('ES5.1', '#sec-15.4.4.16', 'Array.prototype.every')}}{{Spec2('ES5.1')}}Initial definition. Implemented in JavaScript 1.6.
{{SpecName('ES6', '#sec-array.prototype.every', 'Array.prototype.every')}}{{Spec2('ES6')}}
{{SpecName('ESDraft', '#sec-array.prototype.every', 'Array.prototype.every')}}{{Spec2('ESDraft')}}
- -

Browser compatibility

- -
- - -

{{Compat("javascript.builtins.Array.every")}}

-
- -

See also

- - diff --git a/files/tr/web/javascript/reference/global_objects/array/filter/index.html b/files/tr/web/javascript/reference/global_objects/array/filter/index.html deleted file mode 100644 index 4dfc8eaeae..0000000000 --- a/files/tr/web/javascript/reference/global_objects/array/filter/index.html +++ /dev/null @@ -1,243 +0,0 @@ ---- -title: Array.prototype.filter() -slug: Web/JavaScript/Reference/Global_Objects/Array/filter -tags: - - Dizi - - ECMAScript 5 - - JavaScript - - Method - - Prototype - - ployfill -translation_of: Web/JavaScript/Reference/Global_Objects/Array/filter ---- -
{{JSRef}}
- -
 
- -

filter() metotu sağlanan işlev tarafından uygulanan testi geçen tüm öğelerle birlikte yeni bir dizi oluşturur.

- -
{{EmbedInteractiveExample("pages/js/array-filter.html")}}
- - - -

Söz Dizimi

- -
var newArray = arr.filter(callback(element[, index[, array]])[, thisArg])
- -

Parametreler

- -
-
callback
-
Function , dizinin her öğesini sınamak için bir yordamdır. Öğeyi saklamak için true , aksi takdirde false değerini döndürün. Üç argümanı kabul eder:
-
-
-
element
-
Dizide işlenen mevcut elementtir.
-
index{{optional_inline}}
-
Dizide işlenen geçerli öğenin dizini
-
array{{optional_inline}}
-
The array filter was called upon.
-
-
-
thisArg{{optional_inline}}
-
callback  çalıştığı zaman this olarak kullanmak için değerdir.
-
- -

Dönüş değer

- -

Testi geçen öğeler içeren yeni bir dizi. Hiçbir öğe testi geçemezse, boş bir dizi döndürülür.

- -

Açıklama

- -

filter (), bir dizideki her öğe için sağlanan bir geri çağırma işlevini çağırır ve geri çağrmanın (callback) doğru olan bir değer döndürdüğü tüm değerler için yeni bir dizisini oluşturur. Geri çağırma (callback), yalnızca atanmış değerleri olan dizinin dizinleri için çağrılır; silinmiş veya hiçbir zaman değer atanmamış indeksler için çağrılmaz. Filtre testini geçmeyen dizi öğeleri basitçe atlanır ve yeni diziye dahil edilmez.

- -

Geri Çağırma (callback)  3 argüman ile çağırılır.

- -
    -
  1. elementin değeri
  2. -
  3. elementin indeksi
  4. -
  5. Array nesnesinin geçişi
  6. -
- -

Filtrelemek için bir thisArg parametresi varsa, geri çağırma (callback) bu değer olarak kullanılacaktır. Aksi halde undefined değeri bu değer olarak kullanılacaktır. Sonuçta geri çağırma ile gözlenebilen this değeri, bir işlev tarafından görülenlerin belirlenmesi için kullanılan genel kurallara göre belirlenir.

- -

filter() çağrıldığı diziyi değiştirmez.

- -

filter() tarafından işlenen elemanların aralığı, ilk geri çağırma callback çağrısından önce ayarlanır. filter() çağrısı başladıktan sonra diziye eklenen öğeler, geri çağırma  callback tarafından ziyaret edilmeyecektir. Dizinin mevcut elemanları değiştirilir veya silinirse, geri çağırmaya callback iletilen değerleri filter() tarafından ziyaret edilen zamanın değeri olacaktır; silinen öğeler ziyaret edilmez.

- -

Örnekler

- -

Tüm küçük değerleri filtrelemek

- -

Aşağıdaki örnek, tüm öğeleri 10'dan daha küçük değerlere sahip filtreli bir dizi oluşturmak için filter() kullanır.

- -
function isBigEnough(value) {
-  return value >= 10;
-}
-
-var filtered = [12, 5, 8, 130, 44].filter(isBigEnough);
-// filtered is [12, 130, 44]
-
- -

JSON'dan geçersiz girişleri filtrelemek

- -

Aşağıdaki örnek, 0 olmayan,numeric id olan tüm öğelerin filtrelenmiş bir jsonunu oluşturmak için filter() işlevini kullanır. 

- -
var arr = [
-  { id: 15 },
-  { id: -1 },
-  { id: 0 },
-  { id: 3 },
-  { id: 12.2 },
-  { },
-  { id: null },
-  { id: NaN },
-  { id: 'undefined' }
-];
-
-var invalidEntries = 0;
-
-function isNumber(obj) {
-  return obj !== undefined && typeof(obj) === 'number' && !isNaN(obj);
-}
-
-function filterByID(item) {
-  if (isNumber(item.id) && item.id !== 0) {
-    return true;
-  }
-  invalidEntries++;
-  return false;
-}
-
-var arrByID = arr.filter(filterByID);
-
-console.log('Filtered Array\n', arrByID);
-// Filtered Array
-// [{ id: 15 }, { id: -1 }, { id: 3 }, { id: 12.2 }]
-
-console.log('Number of Invalid Entries = ', invalidEntries);
-// Number of Invalid Entries = 5
-
- -

Array içinde arama yapmak

- -

 

- -

Aşağıdaki örnek, arama keriterlerine göre dizi içeriğini filtrelemek için filter() işlevini kullanır

- -

 

- -
var fruits = ['apple', 'banana', 'grapes', 'mango', 'orange'];
-
-/**
- * Array filters items based on search criteria (query)
- */
-function filterItems(query) {
-  return fruits.filter(function(el) {
-      return el.toLowerCase().indexOf(query.toLowerCase()) > -1;
-  })
-}
-
-console.log(filterItems('ap')); // ['apple', 'grapes']
-console.log(filterItems('an')); // ['banana', 'mango', 'orange']
- -

ES2015 İmplementasyonu

- -
const fruits = ['apple', 'banana', 'grapes', 'mango', 'orange'];
-
-/**
- * Array filters items based on search criteria (query)
- */
-const filterItems = (query) => {
-  return fruits.filter(el => el.toLowerCase().indexOf(query.toLowerCase()) > -1);
-};
-
-console.log(filterItems('ap')); // ['apple', 'grapes']
-console.log(filterItems('an')); // ['banana', 'mango', 'orange']
-
-
- -

Polyfill

- -

5. basımda ECMA-262 standardına filter () eklenmiştir; bu nedenle standardın tüm uygulamalarında bulunmayabilir. Bu kodu, komut dosyalarınızın başına aşağıdaki kodu ekleyerek ve doğal olarak desteklemeyen ECMA-262 uygulamalarında filter() kullanımına izin vererek çözebilirsiniz. Bu algoritma, fn.call öğesinin {{jsxref ("Function.prototype.bind ()")}} özgün değerini değerlendirdiğini varsayarsak, ECMA-262, 5. basımda belirtilene tamamen eşdeğerdir ve bu {{jsxref ("Array.prototype.push ()")}} orijinal değerine sahiptir

- -
if (!Array.prototype.filter){
-  Array.prototype.filter = function(func, thisArg) {
-    'use strict';
-    if ( ! ((typeof func === 'Function' || typeof func === 'function') && this) )
-        throw new TypeError();
-
-    var len = this.length >>> 0,
-        res = new Array(len), // preallocate array
-        t = this, c = 0, i = -1;
-    if (thisArg === undefined){
-      while (++i !== len){
-        // checks to see if the key was set
-        if (i in this){
-          if (func(t[i], i, t)){
-            res[c++] = t[i];
-          }
-        }
-      }
-    }
-    else{
-      while (++i !== len){
-        // checks to see if the key was set
-        if (i in this){
-          if (func.call(thisArg, t[i], i, t)){
-            res[c++] = t[i];
-          }
-        }
-      }
-    }
-
-    res.length = c; // shrink down array to proper size
-    return res;
-  };
-}
- -

 

- -

Özellikler

- - - - - - - - - - - - - - - - - - - - - - - - -
ÖzelliklerStatülerYorumlar
{{SpecName('ES5.1', '#sec-15.4.4.20', 'Array.prototype.filter')}}{{Spec2('ES5.1')}}İlk tanım JavaScript 1.6'da uygulanmıştır.
{{SpecName('ES2015', '#sec-array.prototype.filter', 'Array.prototype.filter')}}{{Spec2('ES2015')}} 
{{SpecName('ESDraft', '#sec-array.prototype.filter', 'Array.prototype.filter')}}{{Spec2('ESDraft')}} 
- -

Tarayıcı uyumluluğu

- -
- - -

{{Compat("javascript.builtins.Array.filter")}}

-
- -

Ayrıca bakınız

- - diff --git a/files/tr/web/javascript/reference/global_objects/array/find/index.html b/files/tr/web/javascript/reference/global_objects/array/find/index.html deleted file mode 100644 index 76d5e38687..0000000000 --- a/files/tr/web/javascript/reference/global_objects/array/find/index.html +++ /dev/null @@ -1,205 +0,0 @@ ---- -title: Array.prototype.find() -slug: Web/JavaScript/Reference/Global_Objects/Array/find -translation_of: Web/JavaScript/Reference/Global_Objects/Array/find ---- -
{{JSRef}}
- -

find() metodu parametre olarak verilen, true/false değer döndüren test fonksiyonunu karşılayan dizi içerisindeki ilk elemanın değerini döndürür. Aksi halde {{jsxref("undefined")}} döndürür.

- -
function yeterinceBuyuk(eleman) {
-  return eleman >= 15;
-}
-
-[12, 5, 8, 130, 44].find(yeterinceBuyuk); // 130
- -

Ayrıca {{jsxref("Array.findIndex", "findIndex()")}} metoduna bakınız, bu metod dizi içerisinde bulunan elemanın değeri yerine indeksini döndürür.

- -

Dizi içerisindeki elemanın pozizyonunu bulmak ya da var olup olmadığına bakmak için {{jsxref("Array.prototype.indexOf()")}} veya {{jsxref("Array.prototype.includes()")}} kullanabilirsiniz.

- -

Sözdizim

- -
arr.find(gericagrim[, thisArg])
- -

Parametreler

- -
-
gericagrim
-
Dizi içerisindeki her bir değer için çalıştırılacak fonksiyon, üç parametre alır: -
-
eleman
-
Dizideki işlenen mevcut eleman.
-
indeks
-
Dizideki işlenen mevcut elemanın indeksi.
-
dizi
-
find metodunun çağırıldığı dizi.
-
-
-
thisArg {{Optional_inline}}
-
 gericagrim çalıştığında this olarak kullanılan nesne.
-
- -

Dönüş değeri

- -

Eğer test doğrulanırsa dizi içerisindeki bir değer; değilse, {{jsxref("undefined")}}.

- -

Açıklama

- -

find metodu gericagrim fonksiyonu doğru bir değer döndürene kadar her bir indeks için bir sefer gericagrim fonksiyonunu çalıştırır. Eğer böyle bir eleman bulunduysa, find derhal bu elemanın değerini döndürür. Aksi halde, find {{jsxref("undefined")}} döndürür. gericagrim 0 dan  length - 1 dahil olmak üzere değer atanan ya da atanmayan dizinin her bir elemanı için çağırılır. Bu, aralıklı diziler için sadece değer atanan indeksleri ziyaret eden diğer metodlardan daha verimsiz olduğu anlamına gelmektedir. 

- -

gericagrim üç parametre ile çağırılır: dizi elemanının değeri, dizi elemanının indeksi, ve geçilen dizi nesnesi.

- -

Eğer bir thisArg parametresi find için sağlanırsa, bu parametre gericagrim fonksiyonunun her çağırılışı için this olarak kullanılacaktır. Eğer sağlanmazsa, {{jsxref("undefined")}} kullanılır.

- -

find üzerinde çağırıldığı diziyi değiştirmez.

- -

find tarafından işlenilen elemanların aralığı gericagrim fonksiyonunun ilk çağırılışından önce atanır. find çağırılmaya başlandığından sonra diziye eklenen elemanlar gericagrim tarafından ziyaret edilmeyecektir. Eğer varolan, ziyaret edilmeyen eleman gericagrim tarafından değiştirilirse, bu elemanı ziyaret eden gericagrim fonkisyonuna aktarılan değeri find metodunun bu elemanın indeksini ziyaret edeceği andaki değer olacaktır; silenen elemanlar yine de ziyaret edilecektir.

- -

Örnekler

- -

Dizi içerisindeki nesneyi bir özelliğinden bulmak

- -
var envanter = [
-    {isim: 'elma', miktar: 2},
-    {isim: 'muz', miktar: 0},
-    {isim: 'kiraz', miktar: 5}
-];
-
-function kirazlariBul(meyve) {
-    return meyve.isim === 'kiraz';
-}
-
-console.log(envanter.find(kirazlariBul));
-// { isim: 'kiraz', miktar: 5 }
- -

Dizi içerisindeki bir asal sayıyı bulmak

- -

Aşağıdaki örnek dizi içerisindeki bir asal sayı olan elemanı bulur (ya da eğer asal sayı yoksa {{jsxref("undefined")}} döndürür).

- -
function asalMi(eleman, indeks, dizi) {
-  var baslangic = 2;
-  while (baslangic <= Math.sqrt(eleman)) {
-    if (eleman % baslangic++ < 1) {
-      return false;
-    }
-  }
-  return eleman > 1;
-}
-
-console.log([4, 6, 8, 12].find(asalMi)); // undefined, bulunamadı
-console.log([4, 5, 8, 12].find(asalMi)); // 5
-
- -

Aşağıdaki örnek varolmayan ve silinen elemanların ziyaret edildiğini ve gericağrım fonksiyonuna gönderilen değerin ziyaret edildikleri andaki değerleri olduğunu gösterir.

- -
// İndeks 2, 3 ve 4 için elemanı bulunmayan bir dizi tanımlar
-var a = [0,1,,,,5,6];
-
-// Sadece değer atanmış olanlar değil, tüm indeksleri gösterir
-a.find(function(deger, indeks) {
-  console.log('Ziyaret edilen indeks ' + indeks + ' ve değeri ' + deger);
-});
-
-// Silinenler dahil, bütün indeksleri gösterir
-a.find(function(deger, indeks) {
-
-  // İndeksi 5 olan elamanı birinci iterasyonda siler
-  if (indeks == 0) {
-    console.log('a[5] siliniyor ve değeri ' + a[5]);
-    delete a[5];
-  }
-  // İndeksi 5 olan elaman silinse bile yine de ziyaret edilir
-  console.log('Ziyaret edilen indeks ' + indeks + ' ve değeri ' + deger);
-});
-
-
- -

Polyfill

- -

Bu metod ECMAScript 2015 spesifikasyonuna eklenmiştir ve tüm JavaScript implementasyonlarında kullanıma hazır olmayabilir. Fakat,  aşağıdaki kod parçacığı ile Array.prototype.find polyfill yapabilirsiniz:

- -
// https://tc39.github.io/ecma262/#sec-array.prototype.find
-if (!Array.prototype.find) {
-  Object.defineProperty(Array.prototype, 'find', {
-    value: function(predicate) {
-     // 1. Let O be ? ToObject(this value).
-      if (this == null) {
-        throw new TypeError('"this" is null or not defined');
-      }
-
-      var o = Object(this);
-
-      // 2. Let len be ? ToLength(? Get(O, "length")).
-      var len = o.length >>> 0;
-
-      // 3. If IsCallable(predicate) is false, throw a TypeError exception.
-      if (typeof predicate !== 'function') {
-        throw new TypeError('predicate must be a function');
-      }
-
-      // 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
-      var thisArg = arguments[1];
-
-      // 5. Let k be 0.
-      var k = 0;
-
-      // 6. Repeat, while k < len
-      while (k < len) {
-        // a. Let Pk be ! ToString(k).
-        // b. Let kValue be ? Get(O, Pk).
-        // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
-        // d. If testResult is true, return kValue.
-        var kValue = o[k];
-        if (predicate.call(thisArg, kValue, k, o)) {
-          return kValue;
-        }
-        // e. Increase k by 1.
-        k++;
-      }
-
-      // 7. Return undefined.
-      return undefined;
-    }
-  });
-}
-
- -

Eğer Object.defineProperty desteği bulunmayan tamamen eskimiş JavaScript motorları için ihtiyacınız varsa, Array.prototype metodlarını polyfill yapmamanız en doğrusudur, çünkü bu metodlar numaralandırılabilir olmayan metodlardır.

- -

Spesifikasyonlar

- - - - - - - - - - - - - - - - - - - -
SpesifikasyonDurumAçıklama
{{SpecName('ES2015', '#sec-array.prototype.find', 'Array.prototype.find')}}{{Spec2('ES2015')}}İlk tanım.
{{SpecName('ESDraft', '#sec-array.prototype.find', 'Array.prototype.find')}}{{Spec2('ESDraft')}} 
- -

Tarayıcı uyumluluğu

- -
- - -

{{Compat("javascript.builtins.Array.find")}}

-
- -

Ayrıca bakınız

- - diff --git a/files/tr/web/javascript/reference/global_objects/array/findindex/index.html b/files/tr/web/javascript/reference/global_objects/array/findindex/index.html deleted file mode 100644 index 8933892986..0000000000 --- a/files/tr/web/javascript/reference/global_objects/array/findindex/index.html +++ /dev/null @@ -1,177 +0,0 @@ ---- -title: Array.prototype.findIndex() -slug: Web/JavaScript/Reference/Global_Objects/Array/findIndex -translation_of: Web/JavaScript/Reference/Global_Objects/Array/findIndex ---- -
{{JSRef}}
- -

FindIndex () yöntemi, sağlanan test işlevini karşılayan dizideki ilk öğenin dizinini döndürür. Aksi takdirde -1 iade edilir.

- -
{{EmbedInteractiveExample("pages/js/array-findindex.html")}}
- - - -
 
- -

Ayrıca, dizinde bulunan dizinin yerine bulunan bir öğenin değerini döndüren {{jsxref ("Array.find", "find ()")}} yöntemine de bakın.

- -

Syntax

- -
arr.findIndex(callback[, thisArg])
- -

Parameters

- -
-
callback
-
Function to execute on each value in the array, taking three arguments: -
-
element
-
The current element being processed in the array.
-
index{{optional_inline}}
-
The index of the current element being processed in the array.
-
array{{optional_inline}}
-
The array findIndex was called upon.
-
-
-
thisArg{{optional_inline}}
-
Optional. Object to use as this when executing callback.
-
- -

Return value

- -

An index in the array if an element passes the test; otherwise, -1.

- -

Description

- -

The findIndex method executes the callback function once for every array index 0..length-1 (inclusive) in the array until it finds one where callback returns a truthy value (a value that coerces to true). If such an element is found, findIndex immediately returns the index for that iteration. If the callback never returns a truthy value or the array's length is 0, findIndex returns -1. Unlike some other array methods such as Array#some, in sparse arrays the callback is called even for indexes of entries not present in the array.

- -

callback is invoked with three arguments: the value of the element, the index of the element, and the Array object being traversed.

- -

If a thisArg parameter is provided to findIndex, it will be used as the this for each invocation of the callback. If it is not provided, then {{jsxref("undefined")}} is used.

- -

findIndex does not mutate the array on which it is called.

- -

The range of elements processed by findIndex is set before the first invocation of callback. Elements that are appended to the array after the call to findIndex begins will not be visited by callback. If an existing, unvisited element of the array is changed by callback, its value passed to the visiting callback will be the value at the time that findIndex visits that element's index; elements that are deleted are still visited.

- -

Examples

- -

Find the index of a prime number in an array

- -

The following example finds the index of an element in the array that is a prime number (or returns -1 if there is no prime number).

- -
function isPrime(element, index, array) {
-  var start = 2;
-  while (start <= Math.sqrt(element)) {
-    if (element % start < 1) {
-      return false;
-    } else {
-        start++;
-    }
-  }
-  return element > 1;
-}
-
-console.log([4, 6, 8, 12].findIndex(isPrime)); // -1, not found
-console.log([4, 6, 7, 12].findIndex(isPrime)); // 2
-
- -

Find index using arrow function

- -

The following example finds the index of a fruit using an arrow function.

- -
const fruits = ["apple", "banana", "cantaloupe", "blueberries", "grapefruit"];
-
-const index = fruits.findIndex(fruit => fruit === "blueberries");
-
-console.log(index); // 3
-console.log(fruits[index]); // blueberries
-
- -

Polyfill

- -
// https://tc39.github.io/ecma262/#sec-array.prototype.findIndex
-if (!Array.prototype.findIndex) {
-  Object.defineProperty(Array.prototype, 'findIndex', {
-    value: function(predicate) {
-     // 1. Let O be ? ToObject(this value).
-      if (this == null) {
-        throw new TypeError('"this" is null or not defined');
-      }
-
-      var o = Object(this);
-
-      // 2. Let len be ? ToLength(? Get(O, "length")).
-      var len = o.length >>> 0;
-
-      // 3. If IsCallable(predicate) is false, throw a TypeError exception.
-      if (typeof predicate !== 'function') {
-        throw new TypeError('predicate must be a function');
-      }
-
-      // 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
-      var thisArg = arguments[1];
-
-      // 5. Let k be 0.
-      var k = 0;
-
-      // 6. Repeat, while k < len
-      while (k < len) {
-        // a. Let Pk be ! ToString(k).
-        // b. Let kValue be ? Get(O, Pk).
-        // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
-        // d. If testResult is true, return k.
-        var kValue = o[k];
-        if (predicate.call(thisArg, kValue, k, o)) {
-          return k;
-        }
-        // e. Increase k by 1.
-        k++;
-      }
-
-      // 7. Return -1.
-      return -1;
-    },
-    configurable: true,
-    writable: true
-  });
-}
-
- -

If you need to support truly obsolete JavaScript engines that don't support Object.defineProperty, it's best not to polyfill Array.prototype methods at all, as you can't make them non-enumerable.

- -

Specifications

- - - - - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('ES2015', '#sec-array.prototype.findindex', 'Array.prototype.findIndex')}}{{Spec2('ES2015')}}Initial definition.
{{SpecName('ESDraft', '#sec-array.prototype.findIndex', 'Array.prototype.findIndex')}}{{Spec2('ESDraft')}} 
- -

Browser compatibility

- -
- - -

{{Compat("javascript.builtins.Array.findIndex")}}

-
- -

See also

- - diff --git a/files/tr/web/javascript/reference/global_objects/array/foreach/index.html b/files/tr/web/javascript/reference/global_objects/array/foreach/index.html deleted file mode 100644 index 46d677f17a..0000000000 --- a/files/tr/web/javascript/reference/global_objects/array/foreach/index.html +++ /dev/null @@ -1,308 +0,0 @@ ---- -title: Array.prototype.forEach() -slug: Web/JavaScript/Reference/Global_Objects/Array/forEach -translation_of: Web/JavaScript/Reference/Global_Objects/Array/forEach ---- -
{{JSRef}}
- -

forEach() metodu dizideki her eleman için verilen metodu çalıştırır.

- -
{{EmbedInteractiveExample("pages/js/array-foreach.html")}}
- - - -

Syntax

- -
arr.forEach(function callback(currentValue[, index[, array]]) {
-    //your iterator
-}[, thisArg]);
- -

Parametreler

- -
-
callback
-
Aşağıdaki üç parametreyi alan ve dizinin her elemanı için çalışan fonksiyon.
-
-
-
currentValue{{optional_inline}}
-
İşlenmekte olan dizi elemanı.
-
index{{optional_inline}}
-
İşlenmekte olan dizi elemanının indeksi, yani dizideki sırası.
-
array{{optional_inline}}
-
forEach() in uygulanmakta olduğu dizi.
-
-
-
thisArg {{Optional_inline}}
-
-

callback fonksiyonu çağırılırken, fonksiyon içerisinde this yerine kullanılılabilecek değer.

-
-
- -

Dönüş Değeri

- -

{{jsxref("undefined")}}.

- -

Tanım

- -

forEach() tanımlanmış olan callback fonksiyonunu dizideki her eleman için bir kere olmak üzere, indeks sırasına göre artan şekilde çalıştırır. Silinmiş ya da tanımsız olan elemanlar için fonksiyon çalışmaz (örnek: seyrek diziler).

- -

Dizinin

- -

callback çağırılırken aşağıdaki üç parametre kullanılır:

- - - -

If a thisArg parameter is provided to forEach(), it will be used as callback's this value.  Otherwise, the value {{jsxref("undefined")}} will be used as its this value. The this value ultimately observable by callback is determined according to the usual rules for determining the this seen by a function.

- -

The range of elements processed by forEach() is set before the first invocation of callback. Elements that are appended to the array after the call to forEach() begins will not be visited by callback. If the values of existing elements of the array are changed, the value passed to callback will be the value at the time forEach() visits them; elements that are deleted before being visited are not visited. If elements that are already visited are removed (e.g. using {{jsxref("Array.prototype.shift()", "shift()")}}) during the iteration, later elements will be skipped - see example below.

- -

forEach() executes the callback function once for each array element; unlike {{jsxref("Array.prototype.map()", "map()")}} or {{jsxref("Array.prototype.reduce()", "reduce()")}} it always returns the value {{jsxref("undefined")}} and is not chainable. The typical use case is to execute side effects at the end of a chain.

- -

forEach() does not mutate the array on which it is called (although callback, if invoked, may do so).

- -
-

There is no way to stop or break a forEach() loop other than by throwing an exception. If you need such behavior, the forEach() method is the wrong tool.

- -

Early termination may be accomplished with:

- - - -

The other Array methods: {{jsxref("Array.prototype.every()", "every()")}}, {{jsxref("Array.prototype.some()", "some()")}}, {{jsxref("Array.prototype.find()", "find()")}}, and {{jsxref("Array.prototype.findIndex()", "findIndex()")}} test the array elements with a predicate returning a truthy value to determine if further iteration is required.

-
- -

Examples

- -

Converting a for loop to forEach

- -

before

- -
const items = ['item1', 'item2', 'item3'];
-const copy = [];
-
-for (let i=0; i<items.length; i++) {
-  copy.push(items[i])
-}
-
- -

after

- -
const items = ['item1', 'item2', 'item3'];
-const copy = [];
-
-items.forEach(function(item){
-  copy.push(item)
-});
-
-
- -

 

- -

Printing the contents of an array

- -

The following code logs a line for each element in an array:

- -
function logArrayElements(element, index, array) {
-  console.log('a[' + index + '] = ' + element);
-}
-
-// Notice that index 2 is skipped since there is no item at
-// that position in the array.
-[2, 5, , 9].forEach(logArrayElements);
-// logs:
-// a[0] = 2
-// a[1] = 5
-// a[3] = 9
-
- -

Using thisArg

- -

The following (contrived) example updates an object's properties from each entry in the array:

- -
function Counter() {
-  this.sum = 0;
-  this.count = 0;
-}
-Counter.prototype.add = function(array) {
-  array.forEach(function(entry) {
-    this.sum += entry;
-    ++this.count;
-  }, this);
-  // ^---- Note
-};
-
-const obj = new Counter();
-obj.add([2, 5, 9]);
-obj.count;
-// 3
-obj.sum;
-// 16
-
- -

Since the thisArg parameter (this) is provided to forEach(), it is passed to callback each time it's invoked, for use as its this value.

- -
-

If passing the function argument using an arrow function expression the thisArg parameter can be omitted as arrow functions lexically bind the {{jsxref("Operators/this", "this")}} value.

-
- -

An object copy function

- -

The following code creates a copy of a given object. There are different ways to create a copy of an object; the following is just one way and is presented to explain how Array.prototype.forEach() works by using ECMAScript 5 Object.* meta property functions.

- -
function copy(obj) {
-  const copy = Object.create(Object.getPrototypeOf(obj));
-  const propNames = Object.getOwnPropertyNames(obj);
-
-  propNames.forEach(function(name) {
-    const desc = Object.getOwnPropertyDescriptor(obj, name);
-    Object.defineProperty(copy, name, desc);
-  });
-
-  return copy;
-}
-
-const obj1 = { a: 1, b: 2 };
-const obj2 = copy(obj1); // obj2 looks like obj1 now
-
- -

If the array is modified during iteration, other elements might be skipped.

- -

The following example logs "one", "two", "four". When the entry containing the value "two" is reached, the first entry of the whole array is shifted off, which results in all remaining entries moving up one position. Because element "four" is now at an earlier position in the array, "three" will be skipped. forEach() does not make a copy of the array before iterating.

- -
var words = ['one', 'two', 'three', 'four'];
-words.forEach(function(word) {
-  console.log(word);
-  if (word === 'two') {
-    words.shift();
-  }
-});
-// one
-// two
-// four
-
- -

Polyfill

- -

forEach() was added to the ECMA-262 standard in the 5th edition; as such it may not be present in other implementations of the standard. You can work around this by inserting the following code at the beginning of your scripts, allowing use of forEach() in implementations that don't natively support it. This algorithm is exactly the one specified in ECMA-262, 5th edition, assuming {{jsxref("Object")}} and {{jsxref("TypeError")}} have their original values and that callback.call() evaluates to the original value of {{jsxref("Function.prototype.call()")}}.

- -
// Production steps of ECMA-262, Edition 5, 15.4.4.18
-// Reference: http://es5.github.io/#x15.4.4.18
-if (!Array.prototype.forEach) {
-
-  Array.prototype.forEach = function(callback/*, thisArg*/) {
-
-    var T, k;
-
-    if (this == null) {
-      throw new TypeError('this is null or not defined');
-    }
-
-    // 1. Let O be the result of calling toObject() passing the
-    // |this| value as the argument.
-    var O = Object(this);
-
-    // 2. Let lenValue be the result of calling the Get() internal
-    // method of O with the argument "length".
-    // 3. Let len be toUint32(lenValue).
-    var len = O.length >>> 0;
-
-    // 4. If isCallable(callback) is false, throw a TypeError exception.
-    // See: http://es5.github.com/#x9.11
-    if (typeof callback !== 'function') {
-      throw new TypeError(callback + ' is not a function');
-    }
-
-    // 5. If thisArg was supplied, let T be thisArg; else let
-    // T be undefined.
-    if (arguments.length > 1) {
-      T = arguments[1];
-    }
-
-    // 6. Let k be 0.
-    k = 0;
-
-    // 7. Repeat while k < len.
-    while (k < len) {
-
-      var kValue;
-
-      // a. Let Pk be ToString(k).
-      //    This is implicit for LHS operands of the in operator.
-      // b. Let kPresent be the result of calling the HasProperty
-      //    internal method of O with argument Pk.
-      //    This step can be combined with c.
-      // c. If kPresent is true, then
-      if (k in O) {
-
-        // i. Let kValue be the result of calling the Get internal
-        // method of O with argument Pk.
-        kValue = O[k];
-
-        // ii. Call the Call internal method of callback with T as
-        // the this value and argument list containing kValue, k, and O.
-        callback.call(T, kValue, k, O);
-      }
-      // d. Increase k by 1.
-      k++;
-    }
-    // 8. return undefined.
-  };
-}
-
- -

Specifications

- - - - - - - - - - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('ES5.1', '#sec-15.4.4.18', 'Array.prototype.forEach')}}{{Spec2('ES5.1')}}Initial definition. Implemented in JavaScript 1.6.
{{SpecName('ES6', '#sec-array.prototype.foreach', 'Array.prototype.forEach')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-array.prototype.foreach', 'Array.prototype.forEach')}}{{Spec2('ESDraft')}} 
- -

Browser compatibility

- -
- - -

{{Compat("javascript.builtins.Array.forEach")}}

-
- -

See also

- - diff --git a/files/tr/web/javascript/reference/global_objects/array/from/index.html b/files/tr/web/javascript/reference/global_objects/array/from/index.html deleted file mode 100644 index d0d45add78..0000000000 --- a/files/tr/web/javascript/reference/global_objects/array/from/index.html +++ /dev/null @@ -1,258 +0,0 @@ ---- -title: Array.from() -slug: Web/JavaScript/Reference/Global_Objects/Array/from -translation_of: Web/JavaScript/Reference/Global_Objects/Array/from ---- -
{{JSRef}}
- -

Array.from() metodu bir dizi-benzeri veya gezinilebilir bir nesneden yeni bir Dizi örneği oluşturur.

- -
Array.from("birşey");
-// ["b", "i", "r", "ş", "e", "y"]
- -

Söz dizimi

- -
Array.from(arrayLike[, mapFn[, thisArg]])
-
- -

Parametreler

- -
-
arrayLike
-
Diziye çevrilecek olan dizi-benzeri ya da gezinilebilir nesnedir.
-
mapFn
-
İsteğe bağlı. Map fonksiyonu tüm dizi öğeleri için çağrılır.
-
thisArg
-
İsteğe bağlı. mapFn fonksiyonu işletilirken kullanılacak olan this argüman değeridir.
-
- -

Dönüş değeri

- -

Yeni bir {{jsxref("Array")}} örneği.

- -

Açıklama

- -

Array.from(), aşağıdaki yapılardan Diziler oluşturmanıza izin verir:

- - - -

Array.from() has an optional parameter mapFn, which allows you to execute a {{jsxref("Array.prototype.map", "map")}} function on each element of the array (or subclass object) that is being created. More clearly, Array.from(obj, mapFn, thisArg) has the same result as Array.from(obj).map(mapFn, thisArg), except that it does not create an intermediate array. This is especially important for certain array subclasses, like typed arrays, since the intermediate array would necessarily have values truncated to fit into the appropriate type.

- -

The length property of the from() method is 1.

- -

In ES2015, the class syntax allows for sub-classing of both built-in and user defined classes; as a result, static methods such as Array.from are "inherited" by subclasses of Array and create new instances of the subclass, not Array.

- -

Örnekler

- -

Bir metinden Dizi oluşturma

- -
Array.from("birşey");
-// ["b", "i", "r", "ş", "e", "y"]
- -

Bir Set nesnesinden Dizi oluşturma

- -
var s = new Set(["birşey", window]);
-Array.from(s);
-// ["birşey", window]
- -

Bir Map nesnesinden Dizi oluşturma

- -
var m = new Map([[1, 2], [2, 4], [4, 8]]);
-Array.from(m);
-// [[1, 2], [2, 4], [4, 8]]
- -

Bir dizi-benzeri nesneden dizi oluşturma (argümanlar)

- -
function f() {
-  return Array.from(arguments);
-}
-
-f(1, 2, 3);
-
-// [1, 2, 3]
- -

Ok işlevleri ve Array.from kullanma

- -
// Bir işlevini, map işlevi olarak kullanıp
-// öğeler üzerinde oynama yapmak
-Array.from([1, 2, 3], x => x + x);
-// [2, 4, 6]
-
-
-// Generate a sequence of numbers
-// Since the array is initialized with `undefined` on each position,
-// the value of `v` below will be `undefined`
-Array.from({length: 5}, (v, i) => i);
-// [0, 1, 2, 3, 4]
-
- -

Polyfill

- -

Array.from was added to the ECMA-262 standard in the 6th edition (ES2015); as such it may not be present in other implementations of the standard. You can work around this by inserting the following code at the beginning of your scripts, allowing use of Array.from in implementations that don't natively support it.  This algorithm is exactly the one specified in ECMA-262, 6th edition, assuming Object and TypeError have their original values and that callback.call evaluates to the original value of {{jsxref("Function.prototype.call")}}. In addition, since true iterables can not be polyfilled, this implementation does not support generic iterables as defined in the 6th edition of ECMA-262.

- -
// Production steps of ECMA-262, Edition 6, 22.1.2.1
-if (!Array.from) {
-  Array.from = (function () {
-    var toStr = Object.prototype.toString;
-    var isCallable = function (fn) {
-      return typeof fn === 'function' || toStr.call(fn) === '[object Function]';
-    };
-    var toInteger = function (value) {
-      var number = Number(value);
-      if (isNaN(number)) { return 0; }
-      if (number === 0 || !isFinite(number)) { return number; }
-      return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));
-    };
-    var maxSafeInteger = Math.pow(2, 53) - 1;
-    var toLength = function (value) {
-      var len = toInteger(value);
-      return Math.min(Math.max(len, 0), maxSafeInteger);
-    };
-
-    // The length property of the from method is 1.
-    return function from(arrayLike/*, mapFn, thisArg */) {
-      // 1. Let C be the this value.
-      var C = this;
-
-      // 2. Let items be ToObject(arrayLike).
-      var items = Object(arrayLike);
-
-      // 3. ReturnIfAbrupt(items).
-      if (arrayLike == null) {
-        throw new TypeError("Array.from requires an array-like object - not null or undefined");
-      }
-
-      // 4. If mapfn is undefined, then let mapping be false.
-      var mapFn = arguments.length > 1 ? arguments[1] : void undefined;
-      var T;
-      if (typeof mapFn !== 'undefined') {
-        // 5. else
-        // 5. a If IsCallable(mapfn) is false, throw a TypeError exception.
-        if (!isCallable(mapFn)) {
-          throw new TypeError('Array.from: when provided, the second argument must be a function');
-        }
-
-        // 5. b. If thisArg was supplied, let T be thisArg; else let T be undefined.
-        if (arguments.length > 2) {
-          T = arguments[2];
-        }
-      }
-
-      // 10. Let lenValue be Get(items, "length").
-      // 11. Let len be ToLength(lenValue).
-      var len = toLength(items.length);
-
-      // 13. If IsConstructor(C) is true, then
-      // 13. a. Let A be the result of calling the [[Construct]] internal method
-      // of C with an argument list containing the single item len.
-      // 14. a. Else, Let A be ArrayCreate(len).
-      var A = isCallable(C) ? Object(new C(len)) : new Array(len);
-
-      // 16. Let k be 0.
-      var k = 0;
-      // 17. Repeat, while k < len… (also steps a - h)
-      var kValue;
-      while (k < len) {
-        kValue = items[k];
-        if (mapFn) {
-          A[k] = typeof T === 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k);
-        } else {
-          A[k] = kValue;
-        }
-        k += 1;
-      }
-      // 18. Let putStatus be Put(A, "length", len, true).
-      A.length = len;
-      // 20. Return A.
-      return A;
-    };
-  }());
-}
-
- -

Specifications

- - - - - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('ES6', '#sec-array.from', 'Array.from')}}{{Spec2('ES6')}}Initial definition.
{{SpecName('ESDraft', '#sec-array.from', 'Array.from')}}{{Spec2('ESDraft')}}
- -

Browser compatibility

- -
{{CompatibilityTable}}
- -
- - - - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)EdgeInternet ExplorerOperaSafari
Basic support{{CompatChrome("45")}}{{CompatGeckoDesktop("32")}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatVersionUnknown}}9.0
-
- -
- - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("32")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
-
- -

See also

- - diff --git a/files/tr/web/javascript/reference/global_objects/array/includes/index.html b/files/tr/web/javascript/reference/global_objects/array/includes/index.html deleted file mode 100644 index 7ccb8cebc9..0000000000 --- a/files/tr/web/javascript/reference/global_objects/array/includes/index.html +++ /dev/null @@ -1,176 +0,0 @@ ---- -title: Array.prototype.includes() -slug: Web/JavaScript/Reference/Global_Objects/Array/includes -translation_of: Web/JavaScript/Reference/Global_Objects/Array/includes ---- -
{{JSRef}}
- -

includes() metodu bir dizinin belirli bir elemanı içerip içermediğini belirler, içeriyorsa true içermiyorsa false değeri döndürür. Aranan öğenin bulunup bulunmadığını belirlemek için sameValueZero algoritmasını kullanır.

- -
var a = [1, 2, 3];
-a.includes(2); // true
-a.includes(4); // false
-
- -

{{EmbedInteractiveExample("pages/js/array-includes.html")}} 

- -
- -
- -

Söz Dizimi

- -
arr.includes(searchElement)
-arr.includes(searchElement, fromIndex)
-
- -

Parametreler

- -
-
searchElement
-
Aranan eleman.
-
fromIndex {{optional_inline}}
-
Dizide searchElement için aramanın başlatılacağı indis. Negatif bir değer, dizinin sonundan aramaya başlar. Varsayılan değer 0'dır.
-
- -

Return value

- -

A {{jsxref("Boolean")}}.

- -

Örnekler

- -
[1, 2, 3].includes(2);     // true
-[1, 2, 3].includes(4);     // false
-[1, 2, 3].includes(3, 3);  // false
-[1, 2, 3].includes(3, -1); // true
-[1, 2, NaN].includes(NaN); // true
-
- -

fromIndex dizi uzunluğundan büyük veya eşitse

- -

Eğer fromIndex dizinin uzunluğundan büyük veya eşitse, false döndürülür. Dizi aranmaz.

- -
var arr = ['a', 'b', 'c'];
-
-arr.includes('c', 3);   //false
-arr.includes('c', 100); // false
- -

Hesaplanan indis 0'dan küçükse

- -

Eğer fromIndex negatifse, hesaplanan indis, searchElement için aramaya başlanacak konum olarak belirlenir. Hesaplanmış indis 0'dan küçükse, dizinin tamamı aranır.

- -
// array length is 3
-// fromIndex is -100
-// computed index is 3 + (-100) = -97
-
-var arr = ['a', 'b', 'c'];
-
-arr.includes('a', -100); // true
-arr.includes('b', -100); // true
-arr.includes('c', -100); // true
- -

includes() genel bir yöntem olarak kullanılması

- -

includes() yöntemi kasıtlı olarak geneldir. this değerinin bir Array nesnesi türünde olmasını gerektirmez, böylece diğer türlerdeki nesnelere (örn: dizi benzeri nesneler) uygulanabilir. Aşağıdaki örnek, fonksiyonun sahip olduğu argümanlar nesnesi için uygulanan includes() metodunu göstermektedir.

- -
(function() {
-  console.log([].includes.call(arguments, 'a')); // true
-  console.log([].includes.call(arguments, 'd')); // false
-})('a','b','c');
- -

Polyfill

- -
// https://tc39.github.io/ecma262/#sec-array.prototype.includes
-if (!Array.prototype.includes) {
-  Object.defineProperty(Array.prototype, 'includes', {
-    value: function(searchElement, fromIndex) {
-
-      if (this == null) {
-        throw new TypeError('"this" is null or not defined');
-      }
-
-      // 1. Let O be ? ToObject(this value).
-      var o = Object(this);
-
-      // 2. Let len be ? ToLength(? Get(O, "length")).
-      var len = o.length >>> 0;
-
-      // 3. If len is 0, return false.
-      if (len === 0) {
-        return false;
-      }
-
-      // 4. Let n be ? ToInteger(fromIndex).
-      //    (If fromIndex is undefined, this step produces the value 0.)
-      var n = fromIndex | 0;
-
-      // 5. If n ≥ 0, then
-      //  a. Let k be n.
-      // 6. Else n < 0,
-      //  a. Let k be len + n.
-      //  b. If k < 0, let k be 0.
-      var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
-
-      function sameValueZero(x, y) {
-        return x === y || (typeof x === 'number' && typeof y === 'number' && isNaN(x) && isNaN(y));
-      }
-
-      // 7. Repeat, while k < len
-      while (k < len) {
-        // a. Let elementK be the result of ? Get(O, ! ToString(k)).
-        // b. If SameValueZero(searchElement, elementK) is true, return true.
-        if (sameValueZero(o[k], searchElement)) {
-          return true;
-        }
-        // c. Increase k by 1.
-        k++;
-      }
-
-      // 8. Return false
-      return false;
-    }
-  });
-}
-
- -

Object.defineProperty desteklemeyen eski JavaScript motorlarını desteklemeniz gerekiyorsa, Array.prototype metodlarını non-enumerable yapamadığımız için polyfill uygulamamak daha iyidir.

- -

Specifications

- - - - - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('ES7', '#sec-array.prototype.includes', 'Array.prototype.includes')}}{{Spec2('ES7')}}Initial definition.
{{SpecName('ESDraft', '#sec-array.prototype.includes', 'Array.prototype.includes')}}{{Spec2('ESDraft')}} 
- -

Browser compatibility

- -
- - -

{{Compat("javascript.builtins.Array.includes")}}

-
- -

See also

- - diff --git a/files/tr/web/javascript/reference/global_objects/array/index.html b/files/tr/web/javascript/reference/global_objects/array/index.html deleted file mode 100644 index 7cebdbba0f..0000000000 --- a/files/tr/web/javascript/reference/global_objects/array/index.html +++ /dev/null @@ -1,371 +0,0 @@ ---- -title: Diziler -slug: Web/JavaScript/Reference/Global_Objects/Array -tags: - - Array - - JavaScript -translation_of: Web/JavaScript/Reference/Global_Objects/Array ---- -
{{JSRef}}
- -

JavaScript Array nesnesi, üst düzey, liste benzeri dizi yapıları için kullanılan genel bir nesnedir.

- -

Bir dizi oluşturma

- -
var meyveler = ["Elma", "Muz"];
-
-console.log(meyveler.length);
-// 2
- -

Dizideki (indeks ile) elemana ulaşma

- -
var ilk = meyveler[0];
-// Elma
-
-var son = meyveler[meyveler.length - 1];
-/* Diziler sıfır-tabanlı olduğu için uzunluk-1'inci eleman son elemandır.
-// Muz
- -

Bir dizi üzerinde döngü kurma

- -
meyveler.forEach(function (item, index, array) {
-  console.log(item, index);
-});
-// Elma 0
-// Muz 1
- -

Dizinin sonuna eleman ekleme

- -
var yeniDizi = meyveler.push("Portakal");
-// ["Elma", "Muz", "Portakal"]
- -

Dizi sonundan eleman kaldırma

- -
var son = meyveler.pop(); // Portakal elemanını kaldır(sondan)
-// ["Elma", "Muz"];
- -

Dizi başından eleman kaldırma

- -
var ilk = fruits.shift(); // Elma elemanını kaldır(baştan)
-// ["Muz"];
- -

Dizi başına eleman ekleme

- -
var yeniDizi = fruits.unshift("Çilek") // Başa ekle
-// ["Çilek", "Muz"];
- -

Dizideki elemanın kaçıncı sırada olduğunu bulma

- -
meyveler.push("Mango");
-// ["Çilek", "Muz", "Mango"]
-
-var pos = meyveler.indexOf("Muz");
-// 1
- -

Belirli bir sıradaki elemanı silme

- -
var silinenEleman = meyveler.splice(pos, 1); // bir elemanı kaldırma
-// ["Çilek", "Mango"]
-
- -

Dizi kopyalama

- -
var kopyalananDizi = meyveler.slice(); //
-// ["Çilek", "Mango"]
- -

Söz Dizimi

- -
[element0, element1, ..., elementN]
-new Array(element0, element1, ..., elementN)
-new Array(diziUzunlugu)
-
- -
-

Not: N + 1 = dizi uzunluğu

-
- -
-
element0, element1, ..., elementN
-
Bir dizi new Array() nesnesine verilen argüman dışında(yukarıdaki diziUzunluğu argümanı gibi), verilen elemanlar ile oluşturulabilir.(Yukarıda görüldüğü üzere) Bu özel durum sadece new Array() nesnesiyle (Array Constructor) oluşturulan dizilere uygulanabilir, köşeli parantezler ( [ ve ] ) ile oluşturulan dizilere uygulanamaz.
-
arrayLength (dizi uzunluğu)
-
array nesnesinden sadece 0 ve 232-1 (dahil) arasındaki tam sayılardan biri argüman olarak geçirilebilir.
-
If the only argument passed to the Array constructor is an integer between 0 and 232-1 (inclusive), a new, empty JavaScript array and its length is set to that number. If the argument is any other number, a {{jsxref("Global_Objects/RangeError", "RangeError")}} exception is thrown.
-
- -

Tanım

- -

Diziler liste benzeri nesnelerdir ve dönüştürme, tekrarlama gibi işlemlerini uygulamak için dahili methotlarla gelmektedir. JavaScript dizilerinin ne uzunlukları nede elemanları sabit değildir. Önceden tanımlamak gerekmez. Listenin uzunluğu her daim değişebilir ve dizi elemanları ayrık yerleştirilebilir. JavaScript dizilerin düzenli olmasını garanti etmez. Kullanımı tamamen geliştiricinin kullanım senaryosuna bağlıdır. Genel olarak bu yapı esnek ve kullanışlıdır fakat bu özelliklerin sizin belirli kullanım senaryonuzla uyuşup uyuşmadığını dikkate almalısınız.

- -

Note that you shouldn't use an array as an associative array. You can use plain {{jsxref("Global_Objects/Object", "objects")}} instead, although doing so comes with its own caveats. See the post Lightweight JavaScript dictionaries with arbitrary keys as an example.

- -

Dizi nesnelerine erişme

- -

JS dizileri sıfır-tabanlı'dır. Yani ilk elemanın dizideki index'i 0'dır. Son elemanın index'i {{jsxref("Array.length", "length")}} değerinin bir eksiğine eşittir.

- -
var arr = ["bu ilk eleman", "bu ikinci eleman"];
-console.log(arr[0]);              // ilk elemanı yazdırır
-console.log(arr[1]);              // ikinci elemanı yazdırır
-console.log(arr[arr.length - 1]); // son elemanı yazdırır
-
- -

Dizi öğeleri, {{jsxref("Array.toString", "toString")}} gibi sadece nesne özellikleridir. Geçersiz index numarası ile eleman çağırdığınız zaman undefined değerini alırsınız. Ancak, dizinin bir elemanına aşağıdaki gibi erişmeye çalışırsanız söz dizimi hatası alırsınız, çünkü özellik adı geçerli değildir.

- -
console.log(arr.0); // bir söz dizimi hatasıdır
-
- -

Yukardaki kullanımın söz dizimi hatasına yol açmasında özel bir durum yoktur nokta ile gösterim sayı değeri ile başlayamaz tıpkı değişken tanımlamalarında olduğu gibi. Eğer '3d' isimli bir obje değerine ulaşmak istiyorsanız obj['3d'] çağırımını yapmalısınız.

- -
var years = [1950, 1960, 1970, 1980, 1990, 2000, 2010];
-console.log(years.0);   // söz dizimi hatası
-console.log(years[0]);  // çalışır
-
- -
renderer.3d.setTexture(model, "character.png");     // söz dizimi hatası
-renderer["3d"].setTexture(model, "character.png");  // çalışır
-
- -

Note that in the 3d example, "3d" had to be quoted. It's possible to quote the JavaScript array indexes as well (e.g., years["2"] instead of years[2]), although it's not necessary. The 2 in years[2] eventually gets coerced into a string by the JavaScript engine, anyway, through an implicit toString conversion. It is for this reason that "2" and "02" would refer to two different slots on the years object and the following example logs true:

- -
console.log(years["2"] != years["02"]);
-
- -

Similarly, object properties which happen to be reserved words(!) can only be accessed as string literals in bracket notation:

- -
var promise = {
-  'var'  : 'text',
-  'array': [1, 2, 3, 4]
-};
-
-console.log(promise['array']);
- -

Uzunluk ve sayısal özellikler arasındaki ilişki

- -

Bir JavaScript dizisinin {{jsxref("Array.length", "length")}} özelliği ve sayısal özellikleri bağlıdır. Bir takım ön tanımlı dizi metotları (örn., {{jsxref("Array.join", "join")}}, {{jsxref("Array.slice", "slice")}}, {{jsxref("Array.indexOf", "indexOf")}}, vb.) çağrıldıklarında, dizinin {{jsxref("Array.length", "length")}} özellik değerini hesaba katar. Diğer metotlar (örn., {{jsxref("Array.push", "push")}}, {{jsxref("Array.splice", "splice")}}, vb.) daha çok dizinin {{jsxref("Array.length", "length")}} özelliğinin güncellenmesine neden olur.

- -
var meyveler = [];
-meyveler.push("muz", "elma", "şeftali");
-
-console.log(meyveler.length); // 3
- -

Uygun bir index değeri ile beraber, bir dizi elemanı güncellenirse ve ilgili index sayısı dizi sınırları dışında ise; dizi boyutu, verilen index'e uyum sağlayacak biçimde büyüyecek ve Javascript motoru, dizinin {{jsxref("Array.length", "length")}} özelliğini uygun şekilde güncelleyecektir.

- -
fruits[3] = "mango";
-console.log(fruits[3]);
-console.log(fruits.length); // 4
- -

Uzunluk özelliğini doğrudan ayarlamak, özel bir davranışa neden olur.

- -
fruits.length = 10;
-console.log(fruits);        // Dizi, tanımsız olarak doldurulur
-console.log(fruits.length); // 10
-
- -

Bu özellik {{jsxref("Array.length")}} sayfasında daha ayrıntılı olarak anlatılmıştır.

- -

Bir diziyi eşleşen bir sonuç ile oluşturmak

- -

Bir düzenli ifadeye yollanan metin sonucu bir JavaScript dizisi oluşturulabilir. Bu dizi, eşleşen sonuca ait özellikleri ve ifadeleri içerir. Böyle bir dizi {{jsxref("RegExp.exec")}}, {{jsxref("String.match")}}, ve {{jsxref("String.replace")}} tarafından döndürülür. Bu özellikler ve öğeleri açıklamaya yardımcı olabilmesi için aşağıdaki örneği ve altındaki tabloyu inceleyin.

- -
// Match one d followed by one or more b's followed by one d
-// Remember matched b's and the following d
-// Ignore case
-
-var myRe = /d(b+)(d)/i;
-var myArray = myRe.exec("cdbBdbsbz");
-
- -

Eşleşen sonucun öğeleri ve özellikleri aşağıdaki gibidir:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Özellik/ÖğeAçıklamaÖrnek
inputDüzenli ifadeye yollanan metni işaret eden salt-okunur bir özelliktir.cdbBdbsbz
indexDüzenli ifadeye yollanan metindeki eşleşmenin sıfır-tabanlı ve salt-okunur index özelliğidir.1
[0]Son eşleşen karakteri belirten salt-okunur bir özelliktir.dbBd
[1], ...[n]Read-only elements that specify the parenthesized substring matches, if included in the regular expression. The number of possible parenthesized substrings is unlimited.[1]: bB
- [2]: d
- -

Özellikler

- -
-
{{jsxref("Array.length")}}
-
The Array constructor's length property whose value is 1.
-
{{jsxref("Array.prototype")}}
-
Allows the addition of properties to all array objects.
-
- -

Yöntemler

- -
-
{{jsxref("Array.from()")}} {{experimental_inline}}
-
Bir dizi benzeri veya bir yinelenebilir nesneden yeni bir Dizi örneği oluşturur.
-
{{jsxref("Array.isArray()")}}
-
Eğer bir dizi ise true, değilse false döndürür.
-
{{jsxref("Array.observe()")}} {{experimental_inline}}
-
Asynchronously observes changes to Arrays, similar to {{jsxref("Object.observe()")}} for objects. It provides a stream of changes in order of occurrence.
-
{{jsxref("Array.of()")}} {{experimental_inline}}
-
Creates a new Array instance with a variable number of arguments, regardless of number or type of the arguments.
-
- -

Dizi örnekleri

- -

Tüm dizi örnekleri, {{jsxref("Array.prototype")}} 'dan türer. The prototype object of the Array constructor can be modified to affect all Array instances.

- -

Özellikler

- -
{{page('/tr/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype', 'Properties')}}
- -

Metodlar

- -

Mutator methods

- -
{{page('tr/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype', 'Mutator_methods')}}
- -

Accessor methods

- -
{{page('tr/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype', 'Accessor_methods')}}
- -

Iteration methods

- -
{{page('tr/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype', 'Iteration_methods')}}
- -

Array generic methods

- -

Sometimes you would like to apply array methods to strings or other array-like objects (such as function {{jsxref("Functions/arguments", "arguments", "", 1)}}). By doing this, you treat a string as an array of characters (or otherwise treat a non-array as an array). For example, in order to check that every character in the variable str is a letter, you would write:

- -
function isLetter(character) {
-  return (character >= "a" && character <= "z");
-}
-
-if (Array.prototype.every.call(str, isLetter))
-  alert("The string '" + str + "' contains only letters!");
-
- -

This notation is rather wasteful and JavaScript 1.6 introduced a generic shorthand:

- -
if (Array.every(isLetter, str))
-  alert("The string '" + str + "' contains only letters!");
-
- -

{{jsxref("Global_Objects/String", "Generics", "#String_generic_methods", 1)}} are also available on {{jsxref("Global_Objects/String", "String")}}.

- -

These are currently not part of ECMAScript standards (though the ES6 {{jsxref("Array.from()")}} can be used to achieve this). The following is a shim to allow its use in all browsers:

- -
// Assumes Array extras already present (one may use polyfills for these as well)
-(function () {
-    'use strict';
-
-    var i,
-        // We could also build the array of methods with the following, but the
-        //   getOwnPropertyNames() method is non-shimable:
-        // Object.getOwnPropertyNames(Array).filter(function (methodName) {return typeof Array[methodName] === 'function'});
-        methods = [
-            'join', 'reverse', 'sort', 'push', 'pop', 'shift', 'unshift',
-            'splice', 'concat', 'slice', 'indexOf', 'lastIndexOf',
-            'forEach', 'map', 'reduce', 'reduceRight', 'filter',
-            'some', 'every', 'isArray'
-        ],
-        methodCount = methods.length,
-        assignArrayGeneric = function (methodName) {
-            var method = Array.prototype[methodName];
-            Array[methodName] = function (arg1) {
-                return method.apply(arg1, Array.prototype.slice.call(arguments, 1));
-            };
-        };
-
-    for (i = 0; i < methodCount; i++) {
-        assignArrayGeneric(methods[i]);
-    }
-}());
- -

Örnekler

- -

Bir dizi oluşturmak

- -

Aşağıdaki örnekte uzunluğu [0] olan bir dizi tanımlanıyor(msgArray), daha sonra msgArray[0] ve msgArray[99] indexlerine değer atanıyor ve böylece dizinin uzunluğu 100'e çıkıyor.

- -
var msgArray = new Array();
-msgArray[0] = "Hello";
-msgArray[99] = "world";
-
-if (msgArray.length == 100)
-   print("The length is 100.");
-
- -

2 boyutlu dizi oluşturmak

- -

Aşağıdaki örnekte elemanları stringler olan 2 boyutlu bir diziden oluşturulmuş satranç tahtası bulunuyor. İlk hamle 'p' elemanının 6,4 indeksinden 4,4 indexine kopyalanarak yapılmış. Eski bulunduğu index olan 6,4 boş olarak işaretlenmiş.

- -
var board =
-[ ['R','N','B','Q','K','B','N','R'],
-  ['P','P','P','P','P','P','P','P'],
-  [' ',' ',' ',' ',' ',' ',' ',' '],
-  [' ',' ',' ',' ',' ',' ',' ',' '],
-  [' ',' ',' ',' ',' ',' ',' ',' '],
-  [' ',' ',' ',' ',' ',' ',' ',' '],
-  ['p','p','p','p','p','p','p','p'],
-  ['r','n','b','q','k','b','n','r']];
-print(board.join('\n') + '\n\n');
-
-// Move King's Pawn forward 2
-board[4][4] = board[6][4];
-board[6][4] = ' ';
-print(board.join('\n'));
-
- -

Çıktı:

- -
R,N,B,Q,K,B,N,R
-P,P,P,P,P,P,P,P
- , , , , , , ,
- , , , , , , ,
- , , , , , , ,
- , , , , , , ,
-p,p,p,p,p,p,p,p
-r,n,b,q,k,b,n,r
-
-R,N,B,Q,K,B,N,R
-P,P,P,P,P,P,P,P
- , , , , , , ,
- , , , , , , ,
- , , , ,p, , ,
- , , , , , , ,
-p,p,p,p, ,p,p,p
-r,n,b,q,k,b,n,r
-
- -

Tarayıcı Uyumluluk Tablosu

- -

{{Compat("javascript.builtins.Array")}}

- -

Daha fazlası

- - diff --git a/files/tr/web/javascript/reference/global_objects/array/indexof/index.html b/files/tr/web/javascript/reference/global_objects/array/indexof/index.html deleted file mode 100644 index f53a9980d7..0000000000 --- a/files/tr/web/javascript/reference/global_objects/array/indexof/index.html +++ /dev/null @@ -1,246 +0,0 @@ ---- -title: Array.prototype.indexOf() -slug: Web/JavaScript/Reference/Global_Objects/Array/indexOf -translation_of: Web/JavaScript/Reference/Global_Objects/Array/indexOf ---- -
{{JSRef}}
- -

indexOf() metodu, argüman olarak verilen elemanın array de ilk görüldüğü index'i verir. Eğer bu eleman array de bulunmuyorsa -1 değeri döner.

- -
var a = [2, 9, 9];
-a.indexOf(2); // 0
-a.indexOf(7); // -1
-
-if (a.indexOf(7) === -1) {
-  // eleman array de bulunmamaktadır.
-}
-
- -

Yazım

- -
arr.indexOf(aranacakEleman)
-arr.indexOf(aranacakEleman, aramayaBaşlanacakİndex)
-
- -

Parametreler

- -
-
aranacakEleman
-
Array içerisinde aranacak elemanı karşılayacak metod parametresidir.
-
aramayaBaşlanacakİndex{{optional_inline}}
-
Aramaya başlanacak index değerini karşılayacak metod parametresidir. Eğer index olarak gönderilmiş argümanın değeri array'in uzunluğuna eşit veya daha büyükse, metod -1 değerini döndürür, bu array'in hiç aranmayacağı anlamına gelmektedir. Eğer argümanın değeri negatif bir değerse bu durumda argüman değeri array'in sonundan offset olarak algılanacaktır. Not: eğer index argümanı negatif ise, array hala baştan sona aranacaktır. Bu durumda elemanın bulunduğu index negatif hesaplanırsa, bütün array baştan aranacaktır. Default: 0 (tüm array baştan aranacaktır).
-
- -

Dönüş değeri

- -

Elemanın array de ilk görüldüğü index; eğer eleman bulunamazsa -1 dir.

- -

Açıklama

- -

indexOf() aranacakEleman'ı katı eşitlik ilkesine göre dizi elemanları ile karşılaştırır (aynı yöntem === veya üç eşittir operatörü tarafından da kullanılır).

- -

Örnekler

- -

indexOf()'u kullanma

- -

Aşağıdaki örnekte indexOf() metodu kullanılarak, değerlerin bir dizideki konumları bulunuyor.

- -
var array = [2, 9, 9];
-array.indexOf(2);     // 0
-array.indexOf(7);     // -1
-array.indexOf(9, 2);  // 2
-array.indexOf(2, -1); // -1
-array.indexOf(2, -3); // 0
-
- -

Bir öğenin tüm konumlarını bulma

- -
var indices = [];
-var array = ['a', 'b', 'a', 'c', 'a', 'd'];
-var element = 'a';
-var idx = array.indexOf(element);
-while (idx != -1) {
-  indices.push(idx);
-  idx = array.indexOf(element, idx + 1);
-}
-console.log(indices);
-// [0, 2, 4]
-
- -

Bir öğenin dizide olup olmadığını öğrenme ve diziyi güncelleme

- -
function updateVegetablesCollection (veggies, veggie) {
-    if (veggies.indexOf(veggie) === -1) {
-        veggies.push(veggie);
-        console.log('New veggies collection is : ' + veggies);
-    } else if (veggies.indexOf(veggie) > -1) {
-        console.log(veggie + ' already exists in the veggies collection.');
-    }
-}
-
-var veggies = ['potato', 'tomato', 'chillies', 'green-pepper'];
-
-updateVegetablesCollection(veggies, 'spinach');
-// New veggies collection is : potato,tomato,chillies,green-papper,spinach
-updateVegetablesCollection(veggies, 'spinach');
-// spinach already exists in the veggies collection.
-
- -

Polyfill

- -

indexOf() ECMA-262 standartlarına 5. sürümde eklendi; bu yüzden henüz tüm tarayıcılarda mevcut olmayabilir. Aşağıdaki kod parçasını kendi kodunuzun başına ekleyerek kullanabilirsiniz. Böylelikle indexOf() metodunu tarayıcı desteklemese bile kullanabilirsiniz. Aşağıdaki algoritma  {{jsxref("Global_Objects/TypeError", "TypeError")}} ve {{jsxref("Math.abs()")}} öğelerinin orijinal değerlerine sahip olduğu varsayılarak ECMA-262, 5. sürümde belirtilenle eşleşir.

- -
// Production steps of ECMA-262, Edition 5, 15.4.4.14
-// Reference: http://es5.github.io/#x15.4.4.14
-if (!Array.prototype.indexOf) {
-  Array.prototype.indexOf = function(searchElement, fromIndex) {
-
-    var k;
-
-    // 1. Let o be the result of calling ToObject passing
-    //    the this value as the argument.
-    if (this == null) {
-      throw new TypeError('"this" is null or not defined');
-    }
-
-    var o = Object(this);
-
-    // 2. Let lenValue be the result of calling the Get
-    //    internal method of o with the argument "length".
-    // 3. Let len be ToUint32(lenValue).
-    var len = o.length >>> 0;
-
-    // 4. If len is 0, return -1.
-    if (len === 0) {
-      return -1;
-    }
-
-    // 5. If argument fromIndex was passed let n be
-    //    ToInteger(fromIndex); else let n be 0.
-    var n = fromIndex | 0;
-
-    // 6. If n >= len, return -1.
-    if (n >= len) {
-      return -1;
-    }
-
-    // 7. If n >= 0, then Let k be n.
-    // 8. Else, n<0, Let k be len - abs(n).
-    //    If k is less than 0, then let k be 0.
-    k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
-
-    // 9. Repeat, while k < len
-    while (k < len) {
-      // a. Let Pk be ToString(k).
-      //   This is implicit for LHS operands of the in operator
-      // b. Let kPresent be the result of calling the
-      //    HasProperty internal method of o with argument Pk.
-      //   This step can be combined with c
-      // c. If kPresent is true, then
-      //    i.  Let elementK be the result of calling the Get
-      //        internal method of o with the argument ToString(k).
-      //   ii.  Let same be the result of applying the
-      //        Strict Equality Comparison Algorithm to
-      //        searchElement and elementK.
-      //  iii.  If same is true, return k.
-      if (k in o && o[k] === searchElement) {
-        return k;
-      }
-      k++;
-    }
-    return -1;
-  };
-}
-
- -

Specifications

- - - - - - - - - - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('ES5.1', '#sec-15.4.4.14', 'Array.prototype.indexOf')}}{{Spec2('ES5.1')}}Initial definition. Implemented in JavaScript 1.6.
{{SpecName('ES6', '#sec-array.prototype.indexof', 'Array.prototype.indexOf')}}{{Spec2('ES6')}}
{{SpecName('ESDraft', '#sec-array.prototype.indexof', 'Array.prototype.indexOf')}}{{Spec2('ESDraft')}}
- -

Browser compatibility

- -
{{CompatibilityTable}}
- -
- - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatVersionUnknown}}{{CompatGeckoDesktop("1.8")}}{{CompatIE("9")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
-
- -
- - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("1.8")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
-
- -

Compatibility notes

- - - -

See also

- - diff --git a/files/tr/web/javascript/reference/global_objects/array/isarray/index.html b/files/tr/web/javascript/reference/global_objects/array/isarray/index.html deleted file mode 100644 index aafa47718c..0000000000 --- a/files/tr/web/javascript/reference/global_objects/array/isarray/index.html +++ /dev/null @@ -1,154 +0,0 @@ ---- -title: Array.isArray() -slug: Web/JavaScript/Reference/Global_Objects/Array/isArray -tags: - - Dizi - - dizi kontrol -translation_of: Web/JavaScript/Reference/Global_Objects/Array/isArray ---- -
{{JSRef}}
- -

Array.isArray() metodu değerin Array olup olmadığını kontrol eder. 

- -

Söz dizimi

- -
Array.isArray(obj)
- -

Parametreler

- -
-
obj
-
Kontrol edilecek nesne.
-
- -

Açıklamalar

- -

Nesne eğer {{jsxref("Array")}} ise true değilse false döndürür.

- -

Daha fazla detay için makaleye göz atın:  “Determining with absolute accuracy whether or not a JavaScript object is an array” 

- -

Örnekler

- -
// Aşağıdaki tüm örnekler true döndürür
-Array.isArray([]);
-Array.isArray([1]);
-Array.isArray(new Array());
-// Az bilinen gerçek: Array.prototype bir dizinin kendisidir:
-Array.isArray(Array.prototype);
-
-// Aşağıdaki tüm örnekler false döndürür
-Array.isArray();
-Array.isArray({});
-Array.isArray(null);
-Array.isArray(undefined);
-Array.isArray(17);
-Array.isArray('Array');
-Array.isArray(true);
-Array.isArray(false);
-Array.isArray({ __proto__: Array.prototype });
-
- -

Kod Parçası

- -

Aşağıdaki kod, diğer kodlardan önce çalıştırılırsa; doğal olarak var olmaması durumunda Array.isArray() 'i oluşturacaktır.

- -
if (!Array.isArray) {
-  Array.isArray = function(arg) {
-    return Object.prototype.toString.call(arg) === '[object Array]';
-  };
-}
-
- -

Tanımlamalar

- - - - - - - - - - - - - - - - - - - - - - - - -
TanımlamaDurumAçıklama
{{SpecName('ES5.1', '#sec-15.4.3.2', 'Array.isArray')}}{{Spec2('ES5.1')}}İlk tanım. JavaScript 1.8.5 sürümünde uygulamaya koyuldu.
{{SpecName('ES6', '#sec-array.isarray', 'Array.isArray')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-array.isarray', 'Array.isArray')}}{{Spec2('ESDraft')}} 
- -

Tarayıcı uyumluluğu

- -

{{CompatibilityTable}}

- -
- - - - - - - - - - - - - - - - - - - -
ÖzellikChromeFirefox (Gecko)Internet ExplorerOperaSafari
Temel Destek{{CompatChrome("5")}}{{CompatGeckoDesktop("2.0")}}{{CompatIE("9")}}{{CompatOpera("10.5")}}{{CompatSafari("5")}}
-
- -
- - - - - - - - - - - - - - - - - - - - - -
ÖzellikAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
- - - - - - - -
Temel Destek 
-
{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("2.0")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
-
- -

Ayrıca bakınız

- - diff --git a/files/tr/web/javascript/reference/global_objects/array/join/index.html b/files/tr/web/javascript/reference/global_objects/array/join/index.html deleted file mode 100644 index 37d876dc97..0000000000 --- a/files/tr/web/javascript/reference/global_objects/array/join/index.html +++ /dev/null @@ -1,107 +0,0 @@ ---- -title: Array.prototype.join() -slug: Web/JavaScript/Reference/Global_Objects/Array/join -translation_of: Web/JavaScript/Reference/Global_Objects/Array/join ---- -
{{JSRef}}
- -

join() metodu bir array içerisinde yer alan bütün elemanları birleştirerek string bir ifade olarak geri döndürür. (veya array benzeri bir obje olarak) Elemanlar varsayılan olarak virgül ile ayıracı ile ayrılır. İsteğe bağlı olarak elementleri birbirinden ayırmak için farklı ayıraçlar da kullanılabilir.

- -
{{EmbedInteractiveExample("pages/js/array-join.html")}}
- - - -

Sözdizimi (Syntax)

- -
arr.join([separator])
- -

Parametreler

- -
-
ayıraç {{optional_inline}}
-
Bir diziye (array) ait elemanları birleştirerek string bir ifade haline getiir. Dizi içinde yer alan elamanları birbirine bağlarken istediğiniz ifadeyi ayıraç olarak kullanabilirsiniz. Eğer ayıraç kullanılmaz ise varsayılan ayıraç olarak virgül kullanılır. Eğer ayıraç olarak boş ifade ("") kullanılırsa, bütün dizinin bütün elemanları birbirine bitişik olacak şekilde dönüştürülür.
-
- -

String ifade oluşturulurken dizi (array) içerisinde yer alan bütün elemanlar kullanılır. Eğer array içerisinde eleman yok ise (array.length değeri sıfıra eşit ise) join metodu boş string ("") döndürür.

- -

Açıklamalar

- -

Dizi (array) içerisinde yer alan bütün elemanları tek bir ifade (string) haline getirir.

- -

 

- -
-

Eğer dizi içerisinde yer alan elemanlardan birinin değeri undefined veya null ise, o eleman boş ifadeye ("") dönüştürülür.

-
- -

Örnekler

- -

Bir arrayi birleştirmenin dört farklı yolu

- -

Aşağıda yer alan örnekte örnekte üç elemandan oluşan a dizisi oluşturup, farklı ayıraçlar kullanarak dört defa birleştirdik. İlk örnekte hiç bir ayıraç kullanmadık, ikinci örnekte virgül ve boşluk, üçüncü örnekte boşluk ve + işareti, son örnekte ise boş ifade (string) değeri kullandık

- -
var a = ['Rüzgar', 'Yağmur', 'Ateş'];
-a.join();      // 'Rüzgar,Yağmur,Ateş'
-a.join(', ');  // 'Rüzgar, Yağmur, Ateş'
-a.join(' + '); // 'Rüzgar + Yağmur + Ateş'
-a.join('');    // 'RüzgarYağmurAteş'
- -

Array benzeri obje nasıl birleştirlir ?

- -

Aşağıda yer alan örnekte array benzeri obje olarak bilinen (argümanlar), yapıyı Array.prototype.join üzerinden call {{jsxref("Function.prototype.call")}} metodu kullanarak birleştireceğiz. 

- -
function f(a, b, c) {
-  var s = Array.prototype.join.call(arguments);
-  console.log(s); // '1,a,true'
-}
-f(1, 'a', true);
-//expected output: "1,a,true"
-
- -

Özellikler

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.1.
{{SpecName('ES5.1', '#sec-15.4.4.5', 'Array.prototype.join')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-array.prototype.join', 'Array.prototype.join')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-array.prototype.join', 'Array.prototype.join')}}{{Spec2('ESDraft')}} 
- -

Tarayıcı Uyumluluğu

- - - -

{{Compat("javascript.builtins.Array.join")}}

- -

See also

- - diff --git a/files/tr/web/javascript/reference/global_objects/array/length/index.html b/files/tr/web/javascript/reference/global_objects/array/length/index.html deleted file mode 100644 index b0ff9d264b..0000000000 --- a/files/tr/web/javascript/reference/global_objects/array/length/index.html +++ /dev/null @@ -1,145 +0,0 @@ ---- -title: Array.length -slug: Web/JavaScript/Reference/Global_Objects/Array/length -tags: - - Dizi - - dizi uzunluğu - - uzunluk -translation_of: Web/JavaScript/Reference/Global_Objects/Array/length ---- -
{{JSRef}}
- -
Dizinin length özelliği -yani uzunluğu-, bir dizideki öğe sayısını döndürür veya ayarlar. 32-bit işaretsiz bir tam sayı (integer) ile ifade edilir, sayısal değeri her zaman dizinin en yüksek değerli index'inden büyüktür.
- -
 
- -
var elemanlar = ["ayakkabılar", "gömlekler", "çoraplar", "kazaklar"];
-elemanlar.length;
-
-// 4 döndürür
- -

Açıklama

- -

Uzunluk(length) özellik değeri, artı işaretli bir tam sayıdır ve değeri 2'nin 32. kuvvetinden küçüktür (232).

- -

Uzunluk(length) özellik değerini ayarlayarak bir diziyi istenen bir zamanda budayabilirsiniz. Bir diziyi length özelliğini ayarlayarak genişletirseniz, asıl öğe sayısı artmayacaktır; örneğin, uzunluğu 2 olan dizinin uzunluğunu 3 olarak ayarlarsanız, dizide hala 2 eleman olacaktır. Bu durumda, length özelliğinin her zaman dizideki tanımlı öğe sayısını göstermesi şart değildir. Ayrıca bkz. Bir diziyi eşleşen bir sonuç ile oluşturmak.

- -

{{js_property_attributes(1, 0, 0)}}

- -

Örnekler

- -

Bir dizi üzerinde gezinim

- -

Aşağıdaki örnekte, numaralar dizisinde, length özelliği kullanılarak gezinim yapılıyor. Her öğe değeri ikiye katlanıyor.

- -
var numaralar = [1, 2, 3, 4, 5];
-var uzunluk = numaralar.length;
-for (var i = 0; i < uzunluk; i++) {
-  numaralar[i] *= 2;
-}
-// numaralar şimdi [2, 4, 6, 8, 10] şeklindedir
-
- -

Bir diziyi kısaltmak

- -

Aşağıdaki örnekte numaralar dizi uzunluğu 3'ten büyükse, dizi kısaltılıyor.

- -
var numaralar = [1, 2, 3, 4, 5];
-
-if (numaralar.length > 3) {
-  numaralar.length = 3;
-}
-
-console.log(numaralar); // [1, 2, 3]
-console.log(numaralar.length); // 3
-
- -

Tanımlamalar

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TanımlamaDurumYorum
{{SpecName('ES1')}}{{Spec2('ES1')}}İlk tanım.
{{SpecName('ES5.1', '#sec-15.4.5.2', 'Array.length')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-properties-of-array-instances-length', 'Array.length')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-properties-of-array-instances-length', 'Array.length')}}{{Spec2('ESDraft')}} 
- -

Tarayıcı uyumluluğu

- -
{{CompatibilityTable}}
- -
- - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
-
- -
- - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
-
- -

Ayrıca bakınız

- - diff --git a/files/tr/web/javascript/reference/global_objects/array/map/index.html b/files/tr/web/javascript/reference/global_objects/array/map/index.html deleted file mode 100644 index 0c8d66f4de..0000000000 --- a/files/tr/web/javascript/reference/global_objects/array/map/index.html +++ /dev/null @@ -1,307 +0,0 @@ ---- -title: Array.prototype.map() -slug: Web/JavaScript/Reference/Global_Objects/Array/map -translation_of: Web/JavaScript/Reference/Global_Objects/Array/map ---- -
{{JSRef}}
- -

map() , dizinin her elemanı için, parametre olarak verilen fonksiyonu çağırır ve oluşan sonuçlarla da yeni bir dizi oluşturur.

- -
{{EmbedInteractiveExample("pages/js/array-map.html")}}
- - - -

Sözdizimi

- -
var new_array = arr.map(function callback(currentValue[, index[, array]]) {
-    // Return element for new_array
-}[, thisArg])
- -

Parameters

- -
-
callback
-
Yeni oluşan dizinin elemanlarını döndürdüğü değerlerle oluşturur, üç parametre alır: -
-
 
-
currentValue
-
Dizinin o anda işlem yapılan elemanı.
-
index{{optional_inline}}
-
Dizinin o anda işlem yapılan elemanının indeksi.
-
array{{optional_inline}}
-
map tarafından çağırılan dizi.
-
-
-
thisArg{{optional_inline}}
-
callback fonsiyonu çalışırken kullanacağı this değeri.
-
- -

Return value

- -

Elemanları, callback fonksiyonunun sonuçları olan yeni bir dizi.

- -

Açıklama

- -

map, kendisine özel tahsis edilmiş geri çağırma (callback) fonksiyonunu çağırarak, sıraya uygun olarak döngüye giren her eleman için sonuçtan yeni bir dizi(array) inşa eder. callback sadece değere tanımlanmış dizinin indeksleri için tetiklenir, undefined de buna dahildir. Dizinin kayıp elemanları için çağrılmaz ( kayıp elemanlar: silinmiş veya hiçbir değere eşitlenmemiş veya oluşmamış indeksleri ifade eder. )

- -

callback şu üç argüman ile tetiklenir; Elemanın değeri, elemanın indeks numarası ve elemanları gezilecek olan dizi objesi...

- -
dizi.map( (deger, index) => /* yapılacak işlem */ ) 
- -

If a thisArg parameter is provided to map, it will be used as callback's this value. Otherwise, the value {{jsxref("undefined")}} will be used as its this value. The this value ultimately observable by callback is determined according to the usual rules for determining the this seen by a function.

- -

map does not mutate the array on which it is called (although callback, if invoked, may do so).

- -

The range of elements processed by map is set before the first invocation of callback. Elements which are appended to the array after the call to map begins will not be visited by callback. If existing elements of the array are changed, their value as passed to callback will be the value at the time map visits them. Elements that are deleted after the call to map begins and before being visited are not visited.
-
- Due to the algorithm defined in the specification if the array which map was called upon is sparse, resulting array will also be sparse keeping same indices blank.

- -

Examples

- -

Mapping an array of numbers to an array of square roots

- -

The following code takes an array of numbers and creates a new array containing the square roots of the numbers in the first array.

- -
var numbers = [1, 4, 9];
-var roots = numbers.map(Math.sqrt);
-// roots is now [1, 2, 3]
-// numbers is still [1, 4, 9]
-
- -

Using map to reformat objects in an array

- -

The following code takes an array of objects and creates a new array containing the newly reformatted objects.

- -
var kvArray = [{key: 1, value: 10},
-               {key: 2, value: 20},
-               {key: 3, value: 30}];
-
-var reformattedArray = kvArray.map(obj =>{
-   var rObj = {};
-   rObj[obj.key] = obj.value;
-   return rObj;
-})
-// reformattedArray is now [{1: 10}, {2: 20}, {3: 30}],
-
-// kvArray is still:
-// [{key: 1, value: 10},
-//  {key: 2, value: 20},
-//  {key: 3, value: 30}]
-
- -

Mapping an array of numbers using a function containing an argument

- -

The following code shows how map works when a function requiring one argument is used with it. The argument will automatically be assigned from each element of the array as map loops through the original array.

- -
var numbers = [1, 4, 9];
-var doubles = numbers.map(function(num) {
-  return num * 2;
-});
-
-// doubles is now [2, 8, 18]
-// numbers is still [1, 4, 9]
-
- -

Using map generically

- -

This example shows how to use map on a {{jsxref("String")}} to get an array of bytes in the ASCII encoding representing the character values:

- -
var map = Array.prototype.map;
-var a = map.call('Hello World', function(x) {
-  return x.charCodeAt(0);
-});
-// a now equals [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]
-
- -

Using map generically querySelectorAll

- -

This example shows how to iterate through a collection of objects collected by querySelectorAll. In this case we get all selected options on the screen and printed on the console:

- -
var elems = document.querySelectorAll('select option:checked');
-var values = Array.prototype.map.call(elems, function(obj) {
-  return obj.value;
-});
-
- -

Easier way would be using {{jsxref("Array.from()")}} method.

- -

Tricky use case

- -

(inspired by this blog post)

- -

It is common to use the callback with one argument (the element being traversed). Certain functions are also commonly used with one argument, even though they take additional optional arguments. These habits may lead to confusing behaviors.

- -
// Consider:
-['1', '2', '3'].map(parseInt);
-// While one could expect [1, 2, 3]
-// The actual result is [1, NaN, NaN]
-
-// parseInt is often used with one argument, but takes two.
-// The first is an expression and the second is the radix.
-// To the callback function, Array.prototype.map passes 3 arguments:
-// the element, the index, the array
-// The third argument is ignored by parseInt, but not the second one,
-// hence the possible confusion. See the blog post for more details
-
-function returnInt(element) {
-  return parseInt(element, 10);
-}
-
-['1', '2', '3'].map(returnInt); // [1, 2, 3]
-// Actual result is an array of numbers (as expected)
-
-// Same as above, but using the concise arrow function syntax
-['1', '2', '3'].map( str => parseInt(str) );
-
-// A simpler way to achieve the above, while avoiding the "gotcha":
-['1', '2', '3'].map(Number); // [1, 2, 3]
-// but unlike `parseInt` will also return a float or (resolved) exponential notation:
-['1.1', '2.2e2', '3e300'].map(Number); // [1.1, 220, 3e+300]
-
- -

One alternative output of the map method being called with parseInt as a parameter runs as follows:

- -
var xs = ['10', '10', '10'];
-
-xs = xs.map(parseInt);
-
-console.log(xs);
-// Actual result of 10,NaN,2 may be unexpected based on the above description.
- -

Polyfill

- -

map was added to the ECMA-262 standard in the 5th edition; as such it may not be present in all implementations of the standard. You can work around this by inserting the following code at the beginning of your scripts, allowing use of map in implementations which do not natively support it. This algorithm is exactly the one specified in ECMA-262, 5th edition, assuming {{jsxref("Object")}}, {{jsxref("TypeError")}}, and {{jsxref("Array")}} have their original values and that callback.call evaluates to the original value of {{jsxref("Function.prototype.call")}}.

- -
// Production steps of ECMA-262, Edition 5, 15.4.4.19
-// Reference: http://es5.github.io/#x15.4.4.19
-if (!Array.prototype.map) {
-
-  Array.prototype.map = function(callback/*, thisArg*/) {
-
-    var T, A, k;
-
-    if (this == null) {
-      throw new TypeError('this is null or not defined');
-    }
-
-    // 1. Let O be the result of calling ToObject passing the |this|
-    //    value as the argument.
-    var O = Object(this);
-
-    // 2. Let lenValue be the result of calling the Get internal
-    //    method of O with the argument "length".
-    // 3. Let len be ToUint32(lenValue).
-    var len = O.length >>> 0;
-
-    // 4. If IsCallable(callback) is false, throw a TypeError exception.
-    // See: http://es5.github.com/#x9.11
-    if (typeof callback !== 'function') {
-      throw new TypeError(callback + ' is not a function');
-    }
-
-    // 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
-    if (arguments.length > 1) {
-      T = arguments[1];
-    }
-
-    // 6. Let A be a new array created as if by the expression new Array(len)
-    //    where Array is the standard built-in constructor with that name and
-    //    len is the value of len.
-    A = new Array(len);
-
-    // 7. Let k be 0
-    k = 0;
-
-    // 8. Repeat, while k < len
-    while (k < len) {
-
-      var kValue, mappedValue;
-
-      // a. Let Pk be ToString(k).
-      //   This is implicit for LHS operands of the in operator
-      // b. Let kPresent be the result of calling the HasProperty internal
-      //    method of O with argument Pk.
-      //   This step can be combined with c
-      // c. If kPresent is true, then
-      if (k in O) {
-
-        // i. Let kValue be the result of calling the Get internal
-        //    method of O with argument Pk.
-        kValue = O[k];
-
-        // ii. Let mappedValue be the result of calling the Call internal
-        //     method of callback with T as the this value and argument
-        //     list containing kValue, k, and O.
-        mappedValue = callback.call(T, kValue, k, O);
-
-        // iii. Call the DefineOwnProperty internal method of A with arguments
-        // Pk, Property Descriptor
-        // { Value: mappedValue,
-        //   Writable: true,
-        //   Enumerable: true,
-        //   Configurable: true },
-        // and false.
-
-        // In browsers that support Object.defineProperty, use the following:
-        // Object.defineProperty(A, k, {
-        //   value: mappedValue,
-        //   writable: true,
-        //   enumerable: true,
-        //   configurable: true
-        // });
-
-        // For best browser support, use the following:
-        A[k] = mappedValue;
-      }
-      // d. Increase k by 1.
-      k++;
-    }
-
-    // 9. return A
-    return A;
-  };
-}
-
- -

Specifications

- - - - - - - - - - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('ES5.1', '#sec-15.4.4.19', 'Array.prototype.map')}}{{Spec2('ES5.1')}}Initial definition. Implemented in JavaScript 1.6.
{{SpecName('ES6', '#sec-array.prototype.map', 'Array.prototype.map')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-array.prototype.map', 'Array.prototype.map')}}{{Spec2('ESDraft')}} 
- -

Browser compatibility

- -
- - -

{{Compat("javascript.builtins.Array.map")}}

-
- -

See also

- - diff --git a/files/tr/web/javascript/reference/global_objects/array/of/index.html b/files/tr/web/javascript/reference/global_objects/array/of/index.html deleted file mode 100644 index 07bd40a430..0000000000 --- a/files/tr/web/javascript/reference/global_objects/array/of/index.html +++ /dev/null @@ -1,98 +0,0 @@ ---- -title: Array.of() -slug: Web/JavaScript/Reference/Global_Objects/Array/of -tags: - - Dizi - - ECMAScript 2015 - - JavaScript - - metod - - polyfill -translation_of: Web/JavaScript/Reference/Global_Objects/Array/of ---- -
{{JSRef}}
- -

Array.of() metodu, verilen argümanları içeren yeni bir dizi (Array) oluşturur. Argüman sayısı ve tipi konusunda herhangi bir kısıtı yoktur.

- -

Array.of() ile Array yapıcı (constructor) arasındaki fark, sayısal argümanları kullanma biçimidir: Array.of(7) tek öğesi 7 olan bir dizi oluştururken, Array(7), 7 öğe kapasiteli -length özelliği 7 olan- boş bir dizi oluşturur (Not: Bu ifade 7 boş yeri olan bir dizi oluştur, kapasitesi kadar tanımsız öğe içeren bir dizi değil).

- -
Array.of(7);       // [7]
-Array.of(1, 2, 3); // [1, 2, 3]
-
-Array(7);          // [ , , , , , , ]
-Array(1, 2, 3);    // [1, 2, 3]
-
- -

Sözdizimi

- -
Array.of(element0[, element1[, ...[, elementN]]])
- -

Parametreler

- -
-
elementN
-
Diziyi oluşturacak öğeler.
-
- -

Dönüş değeri

- -

Yeni bir {{jsxref("Array")}} örneği.

- -

Açıklama

- -

Bu fonksiyon ECMAScript 2015 standardının bir parçasıdır. Daha fazla bilgi için Array.of ve Array.from proposal ve Array.of polyfill linklerine bakabilirsiniz.

- -

Örnekler

- -
Array.of(1);         // [1]
-Array.of(1, 2, 3);   // [1, 2, 3]
-Array.of(undefined); // [undefined]
-
- -

Polyfill

- -

Eğer Array.of() doğal olarak mevcut değilse, aşağıdaki kodu diğer kodlardan önce çalıştırarak oluşturabilirsiniz.

- -
if (!Array.of) {
-  Array.of = function() {
-    return Array.prototype.slice.call(arguments);
-  };
-}
-
- -

Şartnameler

- - - - - - - - - - - - - - - - - - - -
ŞartnameDurumYorum
{{SpecName('ES2015', '#sec-array.of', 'Array.of')}}{{Spec2('ES2015')}}İlk tanım.
{{SpecName('ESDraft', '#sec-array.of', 'Array.of')}}{{Spec2('ESDraft')}} 
- -

Tarayıcı Uyumu

- -
- - -

{{Compat("javascript.builtins.Array.of")}}

-
- -

Ayrıca bakınız

- - diff --git a/files/tr/web/javascript/reference/global_objects/array/pop/index.html b/files/tr/web/javascript/reference/global_objects/array/pop/index.html deleted file mode 100644 index 649cb88921..0000000000 --- a/files/tr/web/javascript/reference/global_objects/array/pop/index.html +++ /dev/null @@ -1,117 +0,0 @@ ---- -title: Array.prototype.pop() -slug: Web/JavaScript/Reference/Global_Objects/Array/pop -translation_of: Web/JavaScript/Reference/Global_Objects/Array/pop ---- -
{{JSRef}}
- -

pop() yöntemi, bir dizideki son öğeyi kaldırır ve o öğeyi döndürür. Bu yöntem dizinin uzunluğunu değiştirir.

- - - -
{{EmbedInteractiveExample("pages/js/array-pop.html")}}
- - - -

Syntax

- -
arr.pop()
- -

Return value

- -

The removed element from the array; {{jsxref("undefined")}} if the array is empty.

- -

Description

- -

The pop method removes the last element from an array and returns that value to the caller.

- -

pop is intentionally generic; this method can be {{jsxref("Function.call", "called", "", 1)}} or {{jsxref("Function.apply", "applied", "", 1)}} to objects resembling arrays. Objects which do not contain a length property reflecting the last in a series of consecutive, zero-based numerical properties may not behave in any meaningful manner.

- -

If you call pop() on an empty array, it returns {{jsxref("undefined")}}.

- -

{{jsxref("Array.prototype.shift()")}} has similar behavior to pop, but applied to the first element in an array.

- -

Examples

- -

Removing the last element of an array

- -

The following code creates the myFish array containing four elements, then removes its last element.

- -
var myFish = ['angel', 'clown', 'mandarin', 'sturgeon'];
-
-var popped = myFish.pop();
-
-console.log(myFish); // ['angel', 'clown', 'mandarin' ]
-
-console.log(popped); // 'sturgeon'
- - - -

Using apply( ) or call ( ) on array-like objects

- -

The following code creates the myFish array-like object containing four elements and a length parameter, then removes its last element and decrements the length parameter.

- -
var myFish = {0:'angel', 1:'clown', 2:'mandarin', 3:'sturgeon', length: 4};
-
-var popped = Array.prototype.pop.call(myFish); //same syntax for using apply( )
-
-console.log(myFish); // {0:'angel', 1:'clown', 2:'mandarin', length: 3}
-
-console.log(popped); // 'sturgeon'
-
- - - -

Specifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('ES3')}}{{Spec2('ES3')}}Initial definition. Implemented in JavaScript 1.2.
{{SpecName('ES5.1', '#sec-15.4.4.6', 'Array.prototype.pop')}}{{Spec2('ES5.1')}}
{{SpecName('ES6', '#sec-array.prototype.pop', 'Array.prototype.pop')}}{{Spec2('ES6')}}
{{SpecName('ESDraft', '#sec-array.prototype.pop', 'Array.prototype.pop')}}{{Spec2('ESDraft')}}
- -

Browser compatibility

- -
- - -

{{Compat("javascript.builtins.Array.pop")}}

-
- -

See also

- - - -
-
-
diff --git a/files/tr/web/javascript/reference/global_objects/array/push/index.html b/files/tr/web/javascript/reference/global_objects/array/push/index.html deleted file mode 100644 index a5cd57980b..0000000000 --- a/files/tr/web/javascript/reference/global_objects/array/push/index.html +++ /dev/null @@ -1,152 +0,0 @@ ---- -title: Array.prototype.push() -slug: Web/JavaScript/Reference/Global_Objects/Array/push -tags: - - Dizi - - JavaScript - - Metot - - Prototype - - Referans -translation_of: Web/JavaScript/Reference/Global_Objects/Array/push ---- -
{{JSRef}}
- -

push() metotu dizinin sonuna bir yada daha fazla element ekler ve dizinin yeni uzunluğunu geri döndürür.

- -

Söz dizimi

- -
arr.push(element1, ..., elementN)
- -

Parametreler

- -
-
elementN
-
Dizinin sonuna eklenecek elementler.
-
- -

Geri döndürür

- -

Nesnenin yeni {{jsxref("Array.length", "length")}} özelliğini metotun çağrılması üzerine geri döndürür.

- -

Tanım

- -

push metotu değerleri bir diziye ekler.

- -

push kasıtlı olarak genelleyicidir. Bu metot benzeyen nesnelerin dizilerinde {{jsxref("Function.call", "call()")}} veya {{jsxref("Function.apply", "apply()")}} ile kullanılabilir. push metotu verilen değerleri eklemeye nereden başlayacağını tespit etmek için length özelliğine dayanır. Eğer length özelliği bir sayıya dönüştürülemezse indeks 0 kabul edilir. Bu durum length özelliğinin bulunmama ihtimalini de kapsar, bu durumda length ayrıca oluşturulacaktır.

- -

Sadece yerel dizi benzeri nesneler {{jsxref("Global_Objects/String", "strings", "", 1)}} olduğu halde stringlerin değişmez olduğu gibi bu metotun uygulamalarına uygun değildirler.

- -

Örnekler

- -

Bir diziye element ekleme

- -

Aşağıda bulunan kod iki elementi bulunan sports dizisini oluşturuyor, daha sonra iki diziye iki element daha ekliyor. total değişkeni dizinin yeni uzunluğunu tutuyor.

- -
var sports = ['soccer', 'baseball'];
-var total = sports.push('football', 'swimming');
-
-console.log(sports); // ['soccer', 'baseball', 'football', 'swimming']
-console.log(total);  // 4
-
- -

İki diziyi birleştirme

- -

Bu örnek ikinci bir diziden bütün elemanları eklemek için {{jsxref("Function.apply", "apply()")}} kullanıyor.

- -
var vegetables = ['parsnip', 'potato'];
-var moreVegs = ['celery', 'beetroot'];
-
-// İkinci diziyi birinciyle birleştir
-// Şuna eşdeğer, vegetables.push('celery', 'beetroot');
-Array.prototype.push.apply(vegetables, moreVegs);
-
-console.log(vegetables); // ['parsnip', 'potato', 'celery', 'beetroot']
-
- -

Şartnameler

- - - - - - - - - - - - - - - - - - - - - - - - -
ŞartnameDurumYorum
{{SpecName('ES3')}}{{Spec2('ES3')}}İlk tanım. JavaScript 1.2'de uygulandı.
{{SpecName('ES5.1', '#sec-15.4.4.7', 'Array.prototype.push')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-array.prototype.push', 'Array.prototype.push')}}{{Spec2('ES6')}} 
- -

Tarayıcı uyumu

- -
{{CompatibilityTable}}
- -
- - - - - - - - - - - - - - - - - - - -
ÖzellikChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basit destek{{CompatChrome("1.0")}}{{CompatGeckoDesktop("1.7")}}{{CompatIE("5.5")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
-
- -
- - - - - - - - - - - - - - - - - - - - - -
ÖzellikAndroidAndroid için ChromeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basit destek{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
-
- -

Ayrıca göz at

- - diff --git a/files/tr/web/javascript/reference/global_objects/array/reverse/index.html b/files/tr/web/javascript/reference/global_objects/array/reverse/index.html deleted file mode 100644 index d9bdb98b76..0000000000 --- a/files/tr/web/javascript/reference/global_objects/array/reverse/index.html +++ /dev/null @@ -1,107 +0,0 @@ ---- -title: Array.prototype.reverse() -slug: Web/JavaScript/Reference/Global_Objects/Array/reverse -tags: - - JavaScript - - dizi ters çevirme - - fonksiyon -translation_of: Web/JavaScript/Reference/Global_Objects/Array/reverse ---- -
{{JSRef}}
- -

reverse() metodu dizi elemanlarını tersten sıralar . Dizinin ilk elemanı son eleman olur, son elemanı ilk eleman olur.

- -
{{EmbedInteractiveExample("pages/js/array-reverse.html")}}
- - - -

Syntax

- -
a.reverse()
- -

Dönen Değer

- -

Ters dizi.

- -

Açıklama

- -

reverse metodu dizinin olduğu halini kalıcı olarak değiştirir ve değiştirilmiş diziyi döndürür.

- -

reverse bilinçli olarak generic metodtur; bu şekilde dizilere benzeyen nesneler çağrılabilir veya uygulanabilir. Bir dizi ardışık, sıfır tabanlı sayısal özellikte sonuncuyu yansıtan length özelliği içermeyen nesneler anlamlı bir şekilde davranmayabilir.

- -

Örnekler

- -

Bir dizideki öğeleri tersine çevirme

- -

Aşağıdaki örnek, üç öğe içeren bir a dizisi oluşturur, ardından diziyi tersine çevirir. reverse() çağrısı, ters çevrilmiş a dizisine bir referans döndürür.

- -
const a = [1, 2, 3];
-
-console.log(a); // [1, 2, 3]
-
-a.reverse();
-
-console.log(a); // [3, 2, 1]
-
-
- -

Dizi benzeri bir nesnedeki öğeleri tersine çevirme

- -

Aşağıdaki örnek, üç öğe ve length özelliği içeren dizi benzeri bir nesne a oluşturur, sonra dizi benzeri nesneyi tersine çevirir. reverse () çağrısı, ters dizi benzeri nesneye a bir referans döndürür.

- -
const a = {0: 1, 1: 2, 2: 3, length: 3};
-
-console.log(a); // {0: 1, 1: 2, 2: 3, length: 3}
-
-Array.prototype.reverse.call(a); //same syntax for using apply()
-
-console.log(a); // {0: 3, 1: 2, 2: 1, length: 3}
-
- -

Özellikler

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ÖzellikDurumYorum
{{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.1.
{{SpecName('ES5.1', '#sec-15.4.4.8', 'Array.prototype.reverse')}}{{Spec2('ES5.1')}}
{{SpecName('ES6', '#sec-array.prototype.reverse', 'Array.prototype.reverse')}}{{Spec2('ES6')}}
{{SpecName('ESDraft', '#sec-array.prototype.reverse', 'Array.prototype.reverse')}}{{Spec2('ESDraft')}}
- -

Tarayıcı Uyumluluğu

- -
- - -

{{Compat("javascript.builtins.Array.reverse")}}

-
- -

See also

- - diff --git a/files/tr/web/javascript/reference/global_objects/array/shift/index.html b/files/tr/web/javascript/reference/global_objects/array/shift/index.html deleted file mode 100644 index 3a85e72ca7..0000000000 --- a/files/tr/web/javascript/reference/global_objects/array/shift/index.html +++ /dev/null @@ -1,112 +0,0 @@ ---- -title: Array.prototype.shift() -slug: Web/JavaScript/Reference/Global_Objects/Array/shift -tags: - - Dizi - - JavaScript - - Prototype - - metod -translation_of: Web/JavaScript/Reference/Global_Objects/Array/shift ---- -
{{JSRef}}
- -

shift() metodu bir dizinin ilk elementini diziden kaldırır ve kaldırılmış bu elementi geri döndürür. Bu metod dizinin boyunu değiştirir.

- -
{{EmbedInteractiveExample("pages/js/array-shift.html")}}
- - - -

Dildizimi

- -
arr.shift()
- -

Dönen değer

- -

Diziden kaldırılan element; eğer dizi boş ise de {{jsxref("undefined")}} değerini döndürür.

- -

Tanımlama

- -

shift metodu sıfırıncı indeksteki elementi kaldırır ve ardışık indeksleri aşağı düşürür, daha sonra kaldırılan değeri geri döndürür. Eğer metod uygulandığında {{jsxref("Array.length", "length")}} değeri 0 ise, {{jsxref("undefined")}} geri döndürür.

- -

shift özellikle geniş kapsamlıdır; bu metod {{jsxref("Function.call", "called", "", 1)}} veya {{jsxref("Function.apply", "applied", "", 1)}} dizilere benzeyen nesnelere de uygulanabilir. Ardışık bir serinin sonuncusu özelliği olan, sıfır-temelli, sayısal özellikleri olan ancak length özelliği bulundurmayan nesneler, anlamli bir davranış göstermeyebilirler.

- -

Örnekler

- -

Bir diziden bir elementi kaldırmak

- -

Aşağıdaki kod  myFish dizisinin ilk elementini kaldırmadan önceki ve kaldırdıktan sonraki halini göstermektedir. Aynı zamanda kaldırılan elementi de gösterir:

- -
var myFish = ['angel', 'clown', 'mandarin', 'surgeon'];
-
-console.log('myFish öncesinde:', JSON.stringify(myFish));
-// myFish öncesinde: ['angel', 'clown', 'mandarin', 'surgeon']
-
-var shifted = myFish.shift();
-
-console.log('myFish sonrasında:', myFish);
-// myFish sonrasında: ['clown', 'mandarin', 'surgeon']
-
-console.log('Bu element kaldırıldı:', shifted);
-// Bu element kaldırıldı: angel
-
- -

shift() metodunu while döngüsü içerisinde kullanmak

- -

shift metodu sıklıkla while döngüsü içerisindeki şartlarda kullanılır . Takip eden örnekte her döngü dizi boşalana kadar bir sonraki elementi diziden kaldıracaktır:

- -
var isimler = ["Andrew", "Edward", "Paul", "Chris" ,"John"];
-
-while( (i = isimler.shift()) !== undefined ) {
-    console.log(i);
-}
-// Andrew, Edward, Paul, Chris, John
-
- -

Özellikler

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ÖzellikDurumAçıklama
{{SpecName('ES3')}}{{Spec2('ES3')}}İlk tanımlama. JavaScript 1.2. de uygulandı.
{{SpecName('ES5.1', '#sec-15.4.4.9', 'Array.prototype.shift')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-array.prototype.shift', 'Array.prototype.shift')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-array.prototype.shift', 'Array.prototype.shift')}}{{Spec2('ESDraft')}} 
- -

Tarayıcı uyumluluğu

- -
- - -

{{Compat("javascript.builtins.Array.shift")}}

-
- -

Ayrıca bakınız

- - diff --git a/files/tr/web/javascript/reference/global_objects/array/sort/index.html b/files/tr/web/javascript/reference/global_objects/array/sort/index.html deleted file mode 100644 index 783a3048f3..0000000000 --- a/files/tr/web/javascript/reference/global_objects/array/sort/index.html +++ /dev/null @@ -1,251 +0,0 @@ ---- -title: Array.prototype.sort() -slug: Web/JavaScript/Reference/Global_Objects/Array/sort -tags: - - Dizi - - Dizi methodu - - Sıralama - - metod -translation_of: Web/JavaScript/Reference/Global_Objects/Array/sort ---- -
{{JSRef}}
- -

sort() metodu dizi ögelerini sıralayarak, ilgili dizini sıralanmış olarak geri döndürür. The default sort order is ascending, built upon converting the elements into strings, then comparing their sequences of UTF-16 code units values.

- -

The time and space complexity of the sort cannot be guaranteed as it depends on the implementation.

- -
{{EmbedInteractiveExample("pages/js/array-sort.html")}}
- - - -

Syntax

- -
arr.sort([compareFunction])
-
- -

Parametreler

- -
-
compareFunction {{optional_inline}}
-
Specifies a function that defines the sort order. If omitted, the array elements are converted to strings, then sorted according to each character's Unicode code point value. -
-
firstEl
-
The first element for comparison.
-
secondEl
-
The second element for comparison.
-
-
-
- -

Geri dönen değer

- -

The sorted array. Note that the array is sorted in place, and no copy is made.

- -

Açıklama

- -

If compareFunction is not supplied, all non-undefined array elements are sorted by converting them to strings and comparing strings in UTF-16 code units order. For example, "banana" comes before "cherry". In a numeric sort, 9 comes before 80, but because numbers are converted to strings, "80" comes before "9" in the Unicode order. All undefined elements are sorted to the end of the array.

- -
-

Note : In UTF-16, Unicode characters above \uFFFF are encoded as two surrogate code units, of the range \uD800-\uDFFF. The value of each code unit is taken separately into account for the comparison. Thus the character formed by the surrogate pair \uD655\uDE55 will be sorted before the character \uFF3A.

-
- -

If compareFunction is supplied, all non-undefined array elements are sorted according to the return value of the compare function (all undefined elements are sorted to the end of the array, with no call to compareFunction). If a and b are two elements being compared, then:

- - - -

So, the compare function has the following form:

- -
function compare(a, b) {
-  if (a is less than b by some ordering criterion) {
-    return -1;
-  }
-  if (a is greater than b by the ordering criterion) {
-    return 1;
-  }
-  // a must be equal to b
-  return 0;
-}
-
- -

To compare numbers instead of strings, the compare function can simply subtract b from a. The following function will sort the array in ascending order (if it doesn't contain Infinity and NaN):

- -
function compareNumbers(a, b) {
-  return a - b;
-}
-
- -

The sort method can be conveniently used with {{jsxref("Operators/function", "function expressions", "", 1)}}:

- -
var numbers = [4, 2, 5, 1, 3];
-numbers.sort(function(a, b) {
-  return a - b;
-});
-console.log(numbers);
-
-// [1, 2, 3, 4, 5]
-
- -

ES2015 provides {{jsxref("Functions/Arrow_functions", "arrow function expressions", "", 1)}} with even shorter syntax.

- -
let numbers = [4, 2, 5, 1, 3];
-numbers.sort((a, b) => a - b);
-console.log(numbers);
-
-// [1, 2, 3, 4, 5]
- -

Objects can be sorted, given the value of one of their properties.

- -
var items = [
-  { name: 'Edward', value: 21 },
-  { name: 'Sharpe', value: 37 },
-  { name: 'And', value: 45 },
-  { name: 'The', value: -12 },
-  { name: 'Magnetic', value: 13 },
-  { name: 'Zeros', value: 37 }
-];
-
-// sort by value
-items.sort(function (a, b) {
-  return a.value - b.value;
-});
-
-// sort by name
-items.sort(function(a, b) {
-  var nameA = a.name.toUpperCase(); // ignore upper and lowercase
-  var nameB = b.name.toUpperCase(); // ignore upper and lowercase
-  if (nameA < nameB) {
-    return -1;
-  }
-  if (nameA > nameB) {
-    return 1;
-  }
-
-  // names must be equal
-  return 0;
-});
- -

Örnekler

- -

Creating, displaying, and sorting an array

- -

The following example creates four arrays and displays the original array, then the sorted arrays. The numeric arrays are sorted without a compare function, then sorted using one.

- -
var stringArray = ['Blue', 'Humpback', 'Beluga'];
-var numericStringArray = ['80', '9', '700'];
-var numberArray = [40, 1, 5, 200];
-var mixedNumericArray = ['80', '9', '700', 40, 1, 5, 200];
-
-function compareNumbers(a, b) {
-  return a - b;
-}
-
-console.log('stringArray:', stringArray.join());
-console.log('Sorted:', stringArray.sort());
-
-console.log('numberArray:', numberArray.join());
-console.log('Sorted without a compare function:', numberArray.sort());
-console.log('Sorted with compareNumbers:', numberArray.sort(compareNumbers));
-
-console.log('numericStringArray:', numericStringArray.join());
-console.log('Sorted without a compare function:', numericStringArray.sort());
-console.log('Sorted with compareNumbers:', numericStringArray.sort(compareNumbers));
-
-console.log('mixedNumericArray:', mixedNumericArray.join());
-console.log('Sorted without a compare function:', mixedNumericArray.sort());
-console.log('Sorted with compareNumbers:', mixedNumericArray.sort(compareNumbers));
-
- -

This example produces the following output. As the output shows, when a compare function is used, numbers sort correctly whether they are numbers or numeric strings.

- -
stringArray: Blue,Humpback,Beluga
-Sorted: Beluga,Blue,Humpback
-
-numberArray: 40,1,5,200
-Sorted without a compare function: 1,200,40,5
-Sorted with compareNumbers: 1,5,40,200
-
-numericStringArray: 80,9,700
-Sorted without a compare function: 700,80,9
-Sorted with compareNumbers: 9,80,700
-
-mixedNumericArray: 80,9,700,40,1,5,200
-Sorted without a compare function: 1,200,40,5,700,80,9
-Sorted with compareNumbers: 1,5,9,40,80,200,700
-
- -

ASCII olmayan karakterleri sıralama

- -

For sorting strings with non-ASCII characters, i.e. strings with accented characters (e, é, è, a, ä, etc.), strings from languages other than English, use {{jsxref("String.localeCompare")}}. This function can compare those characters so they appear in the right order.

- -
var items = ['réservé', 'premier', 'communiqué', 'café', 'adieu', 'éclair'];
-items.sort(function (a, b) {
-  return a.localeCompare(b);
-});
-
-// items is ['adieu', 'café', 'communiqué', 'éclair', 'premier', 'réservé']
-
- -

Map ile sıralama

- -

The compareFunction can be invoked multiple times per element within the array. Depending on the compareFunction's nature, this may yield a high overhead. The more work a compareFunction does and the more elements there are to sort, it may be more efficient to use map for sorting. The idea is to traverse the array once to extract the actual values used for sorting into a temporary array, sort the temporary array, and then traverse the temporary array to achieve the right order.

- -
// the array to be sorted
-var list = ['Delta', 'alpha', 'CHARLIE', 'bravo'];
-
-// temporary array holds objects with position and sort-value
-var mapped = list.map(function(el, i) {
-  return { index: i, value: el.toLowerCase() };
-})
-
-// sorting the mapped array containing the reduced values
-mapped.sort(function(a, b) {
-  if (a.value > b.value) {
-    return 1;
-  }
-  if (a.value < b.value) {
-    return -1;
-  }
-  return 0;
-});
-
-// container for the resulting order
-var result = mapped.map(function(el){
-  return list[el.index];
-});
-
- -

There is an open source library available called mapsort which applies this approach.

- -

Specifications

- - - - - - - - - - -
Specification
{{SpecName('ESDraft', '#sec-array.prototype.sort', 'Array.prototype.sort')}}
- -

Tarayıcı uyumluluğu

- -
- - -

{{Compat("javascript.builtins.Array.sort")}}

-
- -

Bunlarada göz at

- - diff --git a/files/tr/web/javascript/reference/global_objects/array/splice/index.html b/files/tr/web/javascript/reference/global_objects/array/splice/index.html deleted file mode 100644 index b853160481..0000000000 --- a/files/tr/web/javascript/reference/global_objects/array/splice/index.html +++ /dev/null @@ -1,149 +0,0 @@ ---- -title: Array.prototype.splice() -slug: Web/JavaScript/Reference/Global_Objects/Array/splice -tags: - - Dizi - - Referans - - metod - - prototip -translation_of: Web/JavaScript/Reference/Global_Objects/Array/splice ---- -
{{JSRef}}
- -

splice() metodu; bir Dizi'nin içeriklerini, diziye ait öğeleri kaldırarak veya yeni öğeler ekleyerek ve/veya mevcut öğeleri silerek değiştirir.

- -
{{EmbedInteractiveExample("pages/js/array-splice.html")}}
- -

Syntax

- -
array.splice(başlangıç[, silinecekAdet[, item1[, item2[, ...]]]])
-
- -

Parametreler

- -
-
başlangıç
-
Dizi'yi değiştirmek için başlanılacak indeks (0 kökenli indeks). Dizi'nin uzunluğundan daha büyük ise, başlangıç indeksi Dizi'nin uzunluğuna ayarlanacak. Negatif ise, Dizi'nin sonundaki öğeler toplamından başlayacak (-1 kökenli indeks) ve eğer kesin değer Dizi'nin uzunluğundan büyük ise, başlangıç değeri 0 olacak.
-
silinecekAdet {{optional_inline}}
-
Eski Dizi'nden silinecek öğelerin sayısını belirten bir tamsayı.
-
silinecekAdet belirlenmemiş ise, veya değeri dizi.uzunluk - başlangıç 'tan büyük ise (daha sade bir tanımı,  başlangıç başlayarak, Dizi'nde kalmış öğelerin toplam sayısından fazla ise), start sayısından Dizi'nin sonuna kadar yer alan bütün öğeler silinecek.
-
silinecekAdet 0 veya negatif ise, hiçbir öğe silinmeyecek. Bu durumda, en az yeni bir öğe tanımlamalısın (aşağı bkz.).
-
item1, item2, ... {{optional_inline}}
-
Dizi'ne eklenecek olan öğeler, başlangıç indeksinden başlayarak. hiçbir öğe tanımlamaz isen, splice() sadece Dizi'den öğeleri kaldıracak.
-
- -

Geri dönüş değeri

- -

Silinen öğeleri barındıran bir Dizi. Sadece bir öğe silinmiş ise, tek öğeli bir Dizi geri dönülecek. Hiçbir öğe silinmemiş ise, boş bir Dizi dönecek.

- -

Açıklama

- -

Sileceğin öğe sayısından farklı bir sayıda öğe tanımlıyorsan, çağrının sonunda Dizi farklı bir uzunluğa sahip olacak.

- -

Örnekler

- -

2 indeksinden önce 0 öğe sil, ve "drum" öğesini ekle

- -
var myFish = ['angel', 'clown', 'mandarin', 'sturgeon'];
-var removed = myFish.splice(2, 0, 'drum');
-
-// myFish dizi öğeleri ["angel", "clown", "drum", "mandarin", "sturgeon"]
-// silinen [], hiçbir öğe silinmedi
-
- -

3 indeksinden 1 öğe sil

- -
var myFish = ['angel', 'clown', 'drum', 'mandarin', 'sturgeon'];
-var removed = myFish.splice(3, 1);
-
-// silinen ["mandarin"]
-// myFish Dizi'si ["angel", "clown", "drum", "sturgeon"]
-
- -

2 indeksinden 1 öğe sil, ve "trumpet" öğesini ekle

- -
var myFish = ['angel', 'clown', 'drum', 'sturgeon'];
-var silinen = myFish.splice(2, 1, 'trumpet');
-
-// myFish is ["angel", "clown", "trumpet", "sturgeon"]
-// silinen ["drum"]
- -

0 indeksinden başlayarak 2 öğe sil, "parrot", "anemone" ve "blue" öğelerini ekle

- -
var myFish = ['angel', 'clown', 'trumpet', 'sturgeon'];
-var silinen = myFish.splice(0, 2, 'parrot', 'anemone', 'blue');
-
-// myFish is ["parrot", "anemone", "blue", "trumpet", "sturgeon"]
-// silinen ["angel", "clown"]
- -

2 indeksinden 2 öğe sil

- -
var myFish = ['parrot', 'anemone', 'blue', 'trumpet', 'sturgeon'];
-var silinen = myFish.splice(myFish.length - 3, 2);
-
-// myFish is ["parrot", "anemone", "sturgeon"]
-// silinen ["blue", "trumpet"]
- -

-2 indeksinden 1 öğe sil

- -
var myFish = ['angel', 'clown', 'mandarin', 'sturgeon'];
-var silinen = myFish.splice(-2, 1);
-
-// myFish ["angel", "clown", "sturgeon"]
-// silinen ["mandarin"]
- -

2 indeksinden sonra bütün öğeleri sil (2 indeksi de dahil)

- -
var myFish = ['angel', 'clown', 'mandarin', 'sturgeon'];
-var silinen = myFish.splice(2);
-
-// myFish ["angel", "clown"]
-// silinen ["mandarin", "sturgeon"]
- -

Özellikler

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ÖzellikDurumYorum
{{SpecName('ES3')}}{{Spec2('ES3')}}Initial definition. Implemented in JavaScript 1.2.
{{SpecName('ES5.1', '#sec-15.4.4.12', 'Array.prototype.splice')}}{{Spec2('ES5.1')}}
{{SpecName('ES6', '#sec-array.prototype.splice', 'Array.prototype.splice')}}{{Spec2('ES6')}}
{{SpecName('ESDraft', '#sec-array.prototype.splice', 'Array.prototype.splice')}}{{Spec2('ESDraft')}}
- -

Tarayıcı Uyumluluğu

- -
- - -

{{Compat("javascript.builtins.Array.splice")}}

-
- -

Bkz.

- - diff --git a/files/tr/web/javascript/reference/global_objects/array/unshift/index.html b/files/tr/web/javascript/reference/global_objects/array/unshift/index.html deleted file mode 100644 index a34d4d8713..0000000000 --- a/files/tr/web/javascript/reference/global_objects/array/unshift/index.html +++ /dev/null @@ -1,114 +0,0 @@ ---- -title: Array.prototype.unshift() -slug: Web/JavaScript/Reference/Global_Objects/Array/unshift -translation_of: Web/JavaScript/Reference/Global_Objects/Array/unshift ---- -
{{JSRef}}
- -

unshift() metodu dizinin başına bir veya daha fazla element ekler ve yeni dizinin uzunluğunu size geri döndürür.

- -
{{EmbedInteractiveExample("pages/js/array-unshift.html")}}
- -

Sözdizimi Kuralları

- -
dizi.unshift(element1[, ...[, elementN]])
- -

Parametreler

- -
-
elementN
-
Dizinin başına eklenecek değer.
-
- -

Döndürülen değer

- -

Üzerinde işlem yapılan dizinin yeni {{jsxref("Array.length", "length")}} değerini verir.

- -

Açıklama

- -

unshift, girilen değerleri bir dizinin başına ekler.

- -

unshiftkasıtlı olarak geneldir; bu yöntem, benzer nesnelere {{jsxref("Function.call", "called", "", 1)}} veya {{jsxref("Function.apply", "applied", "", 1)}} olabilir. diziler. Birbirini length ardışık, sıfıra dayalı sayısal özellikler dizisinde sonuncuyu yansıtan bir özellik içermeyen nesneler , anlamlı şekilde davranamazlar.

- -

Birden fazla eleman parametre olarak girildiğinde, elemanlar parametre sırasına göre dizinin başına yerleştirilmektedir. Parametreleri ayrı unshift metodlarıyla eklemek ve sadece bir unshift metodunda eklemek aynı sonucu vermez.

- -
let dizi = [4, 5, 6];
-dizi.unshift(1, 2, 3);
-console.log(dizi);
-// [1, 2, 3, 4, 5, 6]
-
-dizi = [4, 5, 6]; // dizi sıfırlanır.
-
-dizi.unshift(1);
-dizi.unshift(2);
-dizi.unshift(3);
-
-console.log(dizi);
-// [3, 2, 1, 4, 5, 6]
-
- -

Örnekler

- -
let dizi = [1, 2];
-
-dizi.unshift(0); // dizinin uzunluğu 3 olur.
-// dizi: [0, 1, 2]
-
-dizi.unshift(-2, -1); // dizinin uzunluğu 5 olur.
-// dizi: [-2, -1, 0, 1, 2]
-
-dizi.unshift([-4, -3]); // dizinin uzunluğu 6 olur.
-// dizi: [[-4, -3], -2, -1, 0, 1, 2]
-
-dizi.unshift([-7, -6], [-5]); // dizinin uzunluğu 8 olur.
-// dizi: [ [-7, -6], [-5], [-4, -3], -2, -1, 0, 1, 2 ]
-
- -

Özellikler

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ÖzellikDurumAçıklama
{{SpecName('ES3')}}{{Spec2('ES3')}}Initial definition. Implemented in JavaScript 1.2.
{{SpecName('ES5.1', '#sec-15.4.4.13', 'Array.prototype.unshift')}}{{Spec2('ES5.1')}}
{{SpecName('ES6', '#sec-array.prototype.unshift', 'Array.prototype.unshift')}}{{Spec2('ES6')}}
{{SpecName('ESDraft', '#sec-array.prototype.unshift', 'Array.prototype.unshift')}}{{Spec2('ESDraft')}}
- -

Tarayıcı desteği

- -
- - -

{{Compat("javascript.builtins.Array.unshift")}}

-
- -

Benzer Makaleler

- - diff --git a/files/tr/web/javascript/reference/global_objects/array/values/index.html b/files/tr/web/javascript/reference/global_objects/array/values/index.html deleted file mode 100644 index 1c949e93a5..0000000000 --- a/files/tr/web/javascript/reference/global_objects/array/values/index.html +++ /dev/null @@ -1,86 +0,0 @@ ---- -title: Array.prototype.values() -slug: Web/JavaScript/Reference/Global_Objects/Array/values -tags: - - Dizi yineleyici - - Iterator - - JavaScript - - metod - - prototip -translation_of: Web/JavaScript/Reference/Global_Objects/Array/values ---- -
{{JSRef}}
- -
 
- -

values() methodu dizideki tüm elemanları içeren yeni bir (Dizi yineleyici)  nesnesi döner

- -
var a = ['e', 'l', 'm', 'a'];
-var yineleyici = a.values();
-
-console.log(yineleyici.next().value); // e
-console.log(yineleyici.next().value); // l
-console.log(yineleyici.next().value); // m
-console.log(yineleyici.next().value); // a
-
-
- -

Sintaks

- -
arr.values()
- -

Dönüş değeri

- -

Yeni bir {{jsxref("Array")}} yineleyici nesne.

- -

Örnekler

- -

for...of loop ile yineleme

- -
var arr = ['e', 'l', 'm', 'a'];
-var yineleyici = arr.values();
-
-for (let harf of yineleyici) {
-  console.log(harf);
-}
-
- -

Specifications

- - - - - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('ES2015', '#sec-array.prototype.values', 'Array.prototype.values')}}{{Spec2('ES2015')}}Initial definition.
{{SpecName('ESDraft', '#sec-array.prototype.values', 'Array.prototype.values')}}{{Spec2('ESDraft')}} 
- -

Web tarayıcı uyumluluğu

- -
- - -

{{Compat("javascript.builtins.Array.values")}}

-
- -

See also

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