diff options
| author | Ryan Johnson <rjohnson@mozilla.com> | 2021-04-29 16:16:42 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-29 16:16:42 -0700 |
| commit | 95aca4b4d8fa62815d4bd412fff1a364f842814a (patch) | |
| tree | 5e57661720fe9058d5c7db637e764800b50f9060 /files/tr/web/javascript/reference/global_objects/object/assign | |
| parent | ee3b1c87e3c8e72ca130943eed260ad642246581 (diff) | |
| download | translated-content-95aca4b4d8fa62815d4bd412fff1a364f842814a.tar.gz translated-content-95aca4b4d8fa62815d4bd412fff1a364f842814a.tar.bz2 translated-content-95aca4b4d8fa62815d4bd412fff1a364f842814a.zip | |
remove retired locales (#699)
Diffstat (limited to 'files/tr/web/javascript/reference/global_objects/object/assign')
| -rw-r--r-- | files/tr/web/javascript/reference/global_objects/object/assign/index.html | 311 |
1 files changed, 0 insertions, 311 deletions
diff --git a/files/tr/web/javascript/reference/global_objects/object/assign/index.html b/files/tr/web/javascript/reference/global_objects/object/assign/index.html deleted file mode 100644 index 9490bcec2d..0000000000 --- a/files/tr/web/javascript/reference/global_objects/object/assign/index.html +++ /dev/null @@ -1,311 +0,0 @@ ---- -title: Object.assign() -slug: Web/JavaScript/Reference/Global_Objects/Object/assign -translation_of: Web/JavaScript/Reference/Global_Objects/Object/assign ---- -<div>{{JSRef}}</div> - -<p><strong><code>Object.assign() </code></strong><code>metodu</code><strong><code> </code></strong><code>bir</code><strong><code> </code></strong><code>ya da daha fazla kaynaktaki sayılabilir özellikteki nesnelerin tüm değerlerini hedef kaynaktaki nesneye kopyalamak için kullanılır. Hedef nesnesini geri döndürür.</code></p> - -<h2 id="Yazım_Şekli">Yazım Şekli</h2> - -<pre class="syntaxbox">Object.assign(<var>hedef_nesne</var>, ...<em>kaynak_nesneler</em>)</pre> - -<h3 id="Değişkenler">Değişkenler</h3> - -<dl> - <dt><code>hedef_nesne</code></dt> - <dd>Kaydedilecek olan hedef nesne.</dd> - <dt><code>kaynak_nesneler</code></dt> - <dd>Kaynak nesne(ler).</dd> -</dl> - -<h3 id="Dönüş_Değeri">Dönüş Değeri</h3> - -<p>Hedef nesne.</p> - -<h2 id="Açıklama">Açıklama</h2> - -<p>Hedef nesnedeki değişkenlerin özellikleri kaynak nesnedeklerle aynı anahtar değerlerine sahipse üzerine yazılır. Daha sonra kaynaklardaki değerler benzer şekilde bir öncekiler gibi üzerine yazılır.</p> - -<p><code>Object.assign() metodu</code> bir kaynak nesnesinden bir hedef nesnesine <code>sadece</code><em> sayılabilir </em>ve sahip olduğu<em> özellikleri</em> kopyalar. Kaynak nesne için <code>[[Get]] ve hedef nesne için [[Set]]'i kullanır, böylelikle <em>getter</em> ve <em>setter</em></code> metodlarını çağırır. Bu nedenle yeni özellikleri sadece kopyalama ya da tanımlamaya karşı hedef nesneye atama yapar. Birleştirme kaynakları <em>getter</em> içeriyorsa, yeni özelliklerin bir prototip halinde birleştirilmesi uygun olmayabilir. Sayılabilir özellikler de dahil olmak üzere özellik tanımlamalarını kopyalamak için, prototiplerdeki {{jsxref("Object.getOwnPropertyDescriptor()")}} yerine {{jsxref("Object.defineProperty()")}} kullanılmalıdır.</p> - -<p>{{jsxref("String")}} ve {{jsxref("Symbol")}} özelliklerin her ikisi de kopyalanır.</p> - -<p>Hata durumunda,örneğin bir özelliklik yazılamaz durumda ise, bir {{jsxref("TypeError")}} durumu oluşacaktır ve hedef nesne değişmeden kalacaktır.</p> - -<p><code>Object.assign() metodu kaynak nesnelerdeki</code> {{jsxref("null")}} ya da {{jsxref("undefined")}} durumlarını fırlatmayacağını not ediniz.</p> - -<h2 id="Örnekler">Örnekler</h2> - -<h3 id="Nesne_klonlama">Nesne klonlama</h3> - -<pre class="brush: js">var obj = { a: 1 }; -var copy = Object.assign({}, obj); -console.log(copy); // { a: 1 } -</pre> - -<h3 id="Deep_Clone" name="Deep_Clone">Derin Klonlamada Bir Uyarı</h3> - -<p>Derin klonlama(kopyalama) için, diğer alternatiflere ihtiyacımız vardır. Çünkü <code>Object.assign() özellikleri kopyalar. Eğer kaynak değeri bir nesnenin referansı ise sadece referans değerini kopyalar.</code></p> - -<pre class="brush: js">function test() { - 'use strict'; - - let obj1 = { a: 0 , b: { c: 0}}; - let obj2 = Object.assign({}, obj1); - console.log(JSON.stringify(obj2)); // { a: 0, b: { c: 0}} - - obj1.a = 1; - console.log(JSON.stringify(obj1)); // { a: 1, b: { c: 0}} - console.log(JSON.stringify(obj2)); // { a: 0, b: { c: 0}} - - obj2.a = 2; - console.log(JSON.stringify(obj1)); // { a: 1, b: { c: 0}} - console.log(JSON.stringify(obj2)); // { a: 2, b: { c: 0}} - - obj2.b.c = 3; - console.log(JSON.stringify(obj1)); // { a: 1, b: { c: 3}} - console.log(JSON.stringify(obj2)); // { a: 2, b: { c: 3}} - - // Deep Clone - obj1 = { a: 0 , b: { c: 0}}; - let obj3 = JSON.parse(JSON.stringify(obj1)); - obj1.a = 4; - obj1.b.c = 4; - console.log(JSON.stringify(obj3)); // { a: 0, b: { c: 0}} -} - -test();</pre> - -<h3 id="Nesneleri_Birleştirme">Nesneleri Birleştirme</h3> - -<pre class="brush: js">var o1 = { a: 1 }; -var o2 = { b: 2 }; -var o3 = { c: 3 }; - -var obj = Object.assign(o1, o2, o3); -console.log(obj); // { a: 1, b: 2, c: 3 } -console.log(o1); // { a: 1, b: 2, c: 3 } // hedef nesnenin kendisi değişti.</pre> - -<h3 id="Nesneleri_Aynı_Özelliklerde_Birleştirme">Nesneleri Aynı Özelliklerde Birleştirme</h3> - -<pre class="brush: js">var o1 = { a: 1, b: 1, c: 1 }; -var o2 = { b: 2, c: 2 }; -var o3 = { c: 3 }; - -var obj = Object.assign({}, o1, o2, o3); -console.log(obj); // { a: 1, b: 2, c: 3 } -</pre> - -<p>Özellikler diğer nesneler tarafından parametreler içindeki sonra gelen aynı özelliklerdeki nesnelerin özellikleri olarak üzerine yazıldı.</p> - -<h3 id="Sembol-Tipdeki_Özellikleri_Kopyalama">Sembol-Tipdeki Özellikleri Kopyalama </h3> - -<pre class="brush: js">var o1 = { a: 1 }; -var o2 = { [Symbol('foo')]: 2 }; - -var obj = Object.assign({}, o1, o2); -console.log(obj); // { a : 1, [Symbol("foo")]: 2 } (cf. bug 1207182 on Firefox) -Object.getOwnPropertySymbols(obj); // [Symbol(foo)] - -</pre> - -<h3 id="Prototipteki_Zincirleme_Özellikler_ve_Sayılamayan_Özellikler_Kopyalanamaz">Prototipteki Zincirleme Özellikler ve Sayılamayan Özellikler Kopyalanamaz</h3> - -<pre class="brush: js">var obj = Object.create({ foo: 1 }, { // foo is on obj's prototype chain. - bar: { - value: 2 // bar sayılamayan özellik - }, - baz: { - value: 3, - enumerable: true // baz sayılabilen özellik - } -}); - -var copy = Object.assign({}, obj); -console.log(copy); // { baz: 3 } - -</pre> - -<h3 id="Değişken_Tipleri_Objelere_Sarmalanır">Değişken Tipleri Objelere Sarmalanır</h3> - -<pre class="brush: js">var v1 = 'abc'; -var v2 = true; -var v3 = 10; -var v4 = Symbol('foo'); - -var obj = Object.assign({}, v1, null, v2, undefined, v3, v4); -// Değişken tipleri sarmalanır, null ve undefined görmezden gelinir. -// Sadece string tipteki değişkenler sayılabilir özelliktedir. -console.log(obj); // { "0": "a", "1": "b", "2": "c" } - -</pre> - -<h3 id="Hatalar_Devam_Eden_Kopyalama_İşlemlerini_Kesintiye_Uğratır">Hatalar Devam Eden Kopyalama İşlemlerini Kesintiye Uğratır</h3> - -<pre class="brush: js">var target = Object.defineProperty({}, 'foo', { - value: 1, - writable: false -}); // target.foo sadece-okunabilir özellik - -Object.assign(target, { bar: 2 }, { foo2: 3, foo: 3, foo3: 3 }, { baz: 4 }); -// TypeError: "foo" sadece-okunabilir özellik -// foo hedefe aktarma sırasında hata fırlatır - -console.log(target.bar); // 2: ilk kaynak başarıyla kopyalandı. -console.log(target.foo2); // 3: ikinci kaynağın ilk özelliği başarıyla kopyalandı. -console.log(target.foo); // 1: burada hata oluşur. -console.log(target.foo3); // undefined: atama metodu bitti, foo3 kopyalanmayacak. -console.log(target.baz); // undefined: üçüncü kaynak da kopyalanmayacak. -</pre> - -<h3 id="Erişimcileri_Kopyalama">Erişimcileri Kopyalama</h3> - -<pre class="brush: js">var obj = { - foo: 1, - get bar() { - return 2; - } -}; - -var copy = Object.assign({}, obj); -console.log(copy); -// { foo: 1, bar: 2 }, the value of copy.bar is obj.bar's getter's return value. - -// This is an assign function that copies full descriptors -function completeAssign(target, ...sources) { - sources.forEach(source => { - let descriptors = Object.keys(source).reduce((descriptors, key) => { - descriptors[key] = Object.getOwnPropertyDescriptor(source, key); - return descriptors; - }, {}); - // by default, Object.assign copies enumerable Symbols too - Object.getOwnPropertySymbols(source).forEach(sym => { - let descriptor = Object.getOwnPropertyDescriptor(source, sym); - if (descriptor.enumerable) { - descriptors[sym] = descriptor; - } - }); - Object.defineProperties(target, descriptors); - }); - return target; -} - -var copy = completeAssign({}, obj); -console.log(copy); -// { foo:1, get bar() { return 2 } } -</pre> - -<h2 id="Polyfill">Polyfill</h2> - -<p> ES5 sembol özelliğine sahip olmadığından {{Glossary("Polyfill","polyfill")}} sembol özelliği desteklenmez:</p> - -<pre class="brush: js">if (typeof Object.assign != 'function') { - Object.assign = function(target, varArgs) { // .length of function is 2 - 'use strict'; - if (target == null) { // TypeError if undefined or null - throw new TypeError('Cannot convert undefined or null to object'); - } - - var to = Object(target); - - for (var index = 1; index < arguments.length; index++) { - var nextSource = arguments[index]; - - if (nextSource != null) { // Skip over if undefined or null - for (var nextKey in nextSource) { - // Avoid bugs when hasOwnProperty is shadowed - if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { - to[nextKey] = nextSource[nextKey]; - } - } - } - } - return to; - }; -} -</pre> - -<h2 id="Belirtimler">Belirtimler</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">Belirtim</th> - <th scope="col">Durumlar</th> - <th scope="col">Açıklama</th> - </tr> - <tr> - <td>{{SpecName('ES2015', '#sec-object.assign', 'Object.assign')}}</td> - <td>{{Spec2('ES2015')}}</td> - <td>Initial definition.</td> - </tr> - <tr> - <td>{{SpecName('ESDraft', '#sec-object.assign', 'Object.assign')}}</td> - <td>{{Spec2('ESDraft')}}</td> - <td></td> - </tr> - </tbody> -</table> - -<h2 id="Tarayıcı_Destekleme_Durumu">Tarayıcı Destekleme Durumu</h2> - -<div>{{CompatibilityTable}}</div> - -<div id="compat-desktop"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Edge</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatChrome("45")}}</td> - <td>{{CompatGeckoDesktop("34")}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatOpera("32")}}</td> - <td>{{CompatSafari("9")}}</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Chrome for Android</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>{{CompatChrome("45")}}</td> - <td>{{CompatGeckoMobile("34")}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatVersionUnknown}}</td> - </tr> - </tbody> -</table> -</div> - -<h2 id="Daha_Fazlası_İçin">Daha Fazlası İçin</h2> - -<ul> - <li>{{jsxref("Object.defineProperties()")}}</li> - <li><a href="/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties">Enumerability and ownership of properties</a></li> -</ul> |
