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/object/assign/index.html | 272 --------------------- .../reference/global_objects/object/index.html | 184 -------------- 2 files changed, 456 deletions(-) delete mode 100644 files/he/web/javascript/reference/global_objects/object/assign/index.html delete mode 100644 files/he/web/javascript/reference/global_objects/object/index.html (limited to 'files/he/web/javascript/reference/global_objects/object') diff --git a/files/he/web/javascript/reference/global_objects/object/assign/index.html b/files/he/web/javascript/reference/global_objects/object/assign/index.html deleted file mode 100644 index 26e424598a..0000000000 --- a/files/he/web/javascript/reference/global_objects/object/assign/index.html +++ /dev/null @@ -1,272 +0,0 @@ ---- -title: Object.assign() -slug: Web/JavaScript/Reference/Global_Objects/Object/assign -translation_of: Web/JavaScript/Reference/Global_Objects/Object/assign ---- -

{{JSRef}}

- -

מתודת Object.assign מעתיקה אובייקט על שלל {{jsxref("Object/propertyIsEnumerable", "מאפייניו", "", "1")}} {{jsxref("Object/hasOwnProperty", "הקיימים", "", "1")}} לאובייקט אחר וממזגת אותם ביחד. המתודה מחזירה את האובייקט שאליו העתקנו את התכונות החדשות. 

- -
תחביר
- -
Object.assign(target, ...sources)
- -

פרמטרים

- -
-
target - אובייקט היעד
-
אובייקט היעד- האובייקט שאליו אנחנו מעתיקים את כל המאפיינים של האובייקט המקורי, כאשר הוא מחזיר את האובייקט אחרי המיזוג.
-
sources - אובייקט המקור
-
-
- -
-
אובייקט המקור - האובייקט מכיל את המאפיינים שאנחנו רוצים להעתיק לאובייקט נוסף. 
-
- -

Return value - הנתון התוצאה

- -

The target object - האובייקט שאליו העתקנו את התכונות של האובייקט המקורי.

- -

תיאור

- -

מאפיינים באובייקט היעד ישוכתבו או ידרסו ע"י המאפיינים של אובייקט המקור אם הם חולקים את אותו ה-{{jsxref("Object/keys", "key", "", 1)}}. מאפיינים חדשים שיוגדו על מאפיינים משותפים (properties) בהמשך ידרסו גם באובייקט היעד וגם באופייקט המקור.

- -

- -

The Object.assign() method only copies enumerable and own properties from a source object to a target object. It uses [[Get]] on the source and [[Set]] on the target, so it will invoke getters and setters. Therefore it assigns properties, versus copying or defining new properties. This may make it unsuitable for merging new properties into a prototype if the merge sources contain getters.

- -

For copying property definitions (including their enumerability) into prototypes, use {{jsxref("Object.getOwnPropertyDescriptor()")}} and {{jsxref("Object.defineProperty()")}} instead.

- -

Both {{jsxref("String")}} and {{jsxref("Symbol")}} properties are copied.

- -

In case of an error, for example if a property is non-writable, a {{jsxref("TypeError")}} is raised, and the target object is changed if any properties are added before the error is raised.

- -
-

Note: Object.assign() does not throw on {{jsxref("null")}} or {{jsxref("undefined")}} sources.

-
- -

Polyfill

- -

This polyfill doesn't support symbol properties, since ES5 doesn't have symbols anyway:

- -
if (typeof Object.assign !== 'function') {
-  // Must be writable: true, enumerable: false, configurable: true
-  Object.defineProperty(Object, "assign", {
-    value: function assign(target, varArgs) { // .length of function is 2
-      'use strict';
-      if (target === null || target === undefined) {
-        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 && nextSource !== undefined) {
-          for (var nextKey in nextSource) {
-            // Avoid bugs when hasOwnProperty is shadowed
-            if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
-              to[nextKey] = nextSource[nextKey];
-            }
-          }
-        }
-      }
-      return to;
-    },
-    writable: true,
-    configurable: true
-  });
-}
-
- -

Examples

- -

Cloning an object

- -
const obj = { a: 1 };
-const copy = Object.assign({}, obj);
-console.log(copy); // { a: 1 }
-
- -

Warning for Deep Clone

- -

For deep cloning, we need to use alternatives, because Object.assign() copies property values.

- -

If the source value is a reference to an object, it only copies the reference value.

- -
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();
- -

Merging objects

- -
const o1 = { a: 1 };
-const o2 = { b: 2 };
-const o3 = { c: 3 };
-
-const obj = Object.assign(o1, o2, o3);
-console.log(obj); // { a: 1, b: 2, c: 3 }
-console.log(o1);  // { a: 1, b: 2, c: 3 }, target object itself is changed.
- -

Merging objects with same properties

- -
const o1 = { a: 1, b: 1, c: 1 };
-const o2 = { b: 2, c: 2 };
-const o3 = { c: 3 };
-
-const obj = Object.assign({}, o1, o2, o3);
-console.log(obj); // { a: 1, b: 2, c: 3 }
- -

The properties are overwritten by other objects that have the same properties later in the parameters order.

- -

Copying symbol-typed properties

- -
const o1 = { a: 1 };
-const o2 = { [Symbol('foo')]: 2 };
-
-const obj = Object.assign({}, o1, o2);
-console.log(obj); // { a : 1, [Symbol("foo")]: 2 } (cf. bug 1207182 on Firefox)
-Object.getOwnPropertySymbols(obj); // [Symbol(foo)]
-
- -

Properties on the prototype chain and non-enumerable properties cannot be copied

- -
const obj = Object.create({ foo: 1 }, { // foo is on obj's prototype chain.
-  bar: {
-    value: 2  // bar is a non-enumerable property.
-  },
-  baz: {
-    value: 3,
-    enumerable: true  // baz is an own enumerable property.
-  }
-});
-
-const copy = Object.assign({}, obj);
-console.log(copy); // { baz: 3 }
-
- -

Primitives will be wrapped to objects

- -
const v1 = 'abc';
-const v2 = true;
-const v3 = 10;
-const v4 = Symbol('foo');
-
-const obj = Object.assign({}, v1, null, v2, undefined, v3, v4);
-// Primitives will be wrapped, null and undefined will be ignored.
-// Note, only string wrappers can have own enumerable properties.
-console.log(obj); // { "0": "a", "1": "b", "2": "c" }
-
- -

Exceptions will interrupt the ongoing copying task

- -
const target = Object.defineProperty({}, 'foo', {
-  value: 1,
-  writable: false
-}); // target.foo is a read-only property
-
-Object.assign(target, { bar: 2 }, { foo2: 3, foo: 3, foo3: 3 }, { baz: 4 });
-// TypeError: "foo" is read-only
-// The Exception is thrown when assigning target.foo
-
-console.log(target.bar);  // 2, the first source was copied successfully.
-console.log(target.foo2); // 3, the first property of the second source was copied successfully.
-console.log(target.foo);  // 1, exception is thrown here.
-console.log(target.foo3); // undefined, assign method has finished, foo3 will not be copied.
-console.log(target.baz);  // undefined, the third source will not be copied either.
-
- -

Copying accessors

- -
const obj = {
-  foo: 1,
-  get bar() {
-    return 2;
-  }
-};
-
-let 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;
-}
-
-copy = completeAssign({}, obj);
-console.log(copy);
-// { foo:1, get bar() { return 2 } }
-
- -

Specifications

- - - - - - - - - - - - -
Specification
{{SpecName('ESDraft', '#sec-object.assign', 'Object.assign')}}
- -

Browser compatibility

- - - -

{{Compat("javascript.builtins.Object.assign")}}

- -

See also

- - diff --git a/files/he/web/javascript/reference/global_objects/object/index.html b/files/he/web/javascript/reference/global_objects/object/index.html deleted file mode 100644 index 9feed92ddc..0000000000 --- a/files/he/web/javascript/reference/global_objects/object/index.html +++ /dev/null @@ -1,184 +0,0 @@ ---- -title: Object -slug: Web/JavaScript/Reference/Global_Objects/Object -tags: - - Constructor - - JavaScript - - NeedsTranslation - - Object - - TopicStub -translation_of: Web/JavaScript/Reference/Global_Objects/Object ---- -
{{JSRef}}
- -

The Object constructor creates an object wrapper.

- -

Syntax

- -
// Object initialiser or literal
-{ [ nameValuePair1[, nameValuePair2[, ...nameValuePairN] ] ] }
-
-// Called as a constructor
-new Object([value])
- -

Parameters

- -
-
nameValuePair1, nameValuePair2, ... nameValuePairN
-
Pairs of names (strings) and values (any value) where the name is separated from the value by a colon.
-
value
-
Any value.
-
- -

Description

- -

The Object constructor creates an object wrapper for the given value. If the value is {{jsxref("null")}} or {{jsxref("undefined")}}, it will create and return an empty object, otherwise, it will return an object of a Type that corresponds to the given value. If the value is an object already, it will return the value.

- -

When called in a non-constructor context, Object behaves identically to new Object().

- -

See also the object initializer / literal syntax.

- -

Properties of the Object constructor

- -
-
Object.length
-
Has a value of 1.
-
{{jsxref("Object.prototype")}}
-
Allows the addition of properties to all objects of type Object.
-
- -

Methods of the Object constructor

- -
-
{{jsxref("Object.assign()")}}
-
Copies the values of all enumerable own properties from one or more source objects to a target object.
-
{{jsxref("Object.create()")}}
-
Creates a new object with the specified prototype object and properties.
-
{{jsxref("Object.defineProperty()")}}
-
Adds the named property described by a given descriptor to an object.
-
{{jsxref("Object.defineProperties()")}}
-
Adds the named properties described by the given descriptors to an object.
-
{{jsxref("Object.entries()")}}
-
Returns an array containing all of the [key, value] pairs of a given object's own enumerable string properties.
-
{{jsxref("Object.freeze()")}}
-
Freezes an object: other code can't delete or change any properties.
-
{{jsxref("Object.fromEntries()")}}
-
Returns a new object from an iterable of key-value pairs (reverses {{jsxref("Object.entries")}}).
-
{{jsxref("Object.getOwnPropertyDescriptor()")}}
-
Returns a property descriptor for a named property on an object.
-
{{jsxref("Object.getOwnPropertyDescriptors()")}}
-
Returns an object containing all own property descriptors for an object.
-
{{jsxref("Object.getOwnPropertyNames()")}}
-
Returns an array containing the names of all of the given object's own enumerable and non-enumerable properties.
-
{{jsxref("Object.getOwnPropertySymbols()")}}
-
Returns an array of all symbol properties found directly upon a given object.
-
{{jsxref("Object.getPrototypeOf()")}}
-
Returns the prototype of the specified object.
-
{{jsxref("Object.is()")}}
-
Compares if two values are the same value. Equates all NaN values (which differs from both Abstract Equality Comparison and Strict Equality Comparison).
-
{{jsxref("Object.isExtensible()")}}
-
Determines if extending of an object is allowed.
-
{{jsxref("Object.isFrozen()")}}
-
Determines if an object was frozen.
-
{{jsxref("Object.isSealed()")}}
-
Determines if an object is sealed.
-
{{jsxref("Object.keys()")}}
-
Returns an array containing the names of all of the given object's own enumerable string properties.
-
{{jsxref("Object.preventExtensions()")}}
-
Prevents any extensions of an object.
-
{{jsxref("Object.seal()")}}
-
Prevents other code from deleting properties of an object.
-
{{jsxref("Object.setPrototypeOf()")}}
-
Sets the prototype (i.e., the internal [[Prototype]] property).
-
{{jsxref("Object.values()")}}
-
Returns an array containing the values that correspond to all of a given object's own enumerable string properties.
-
- -

Object instances and Object prototype object

- -

All objects in JavaScript are descended from Object; all objects inherit methods and properties from {{jsxref("Object.prototype")}}, although they may be overridden. For example, other constructors' prototypes override the constructor property and provide their own toString() methods. Changes to the Object prototype object are propagated to all objects unless the properties and methods subject to those changes are overridden further along the prototype chain.

- -

Properties

- -
{{page('/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/prototype', 'Properties') }}
- -

Methods

- -
{{page('/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/prototype', 'Methods') }}
- -

Deleting a property from an object

- -

There isn't any method in an Object itself to delete its own properties (e.g. like Map.prototype.delete()). To do so one has to use the delete operator.

- -

Examples

- -

Using Object given undefined and null types

- -

The following examples store an empty Object object in o:

- -
var o = new Object();
-
- -
var o = new Object(undefined);
-
- -
var o = new Object(null);
-
- -

Using Object to create Boolean objects

- -

The following examples store {{jsxref("Boolean")}} objects in o:

- -
// equivalent to o = new Boolean(true);
-var o = new Object(true);
-
- -
// equivalent to o = new Boolean(false);
-var o = new Object(Boolean());
-
- -

Specifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.2', 'Object')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-object-objects', 'Object')}}{{Spec2('ES6')}}Added Object.assign, Object.getOwnPropertySymbols, Object.setPrototypeOf, Object.is
{{SpecName('ESDraft', '#sec-object-objects', 'Object')}}{{Spec2('ESDraft')}}Added Object.entries, Object.values and Object.getOwnPropertyDescriptors.
- -

Browser compatibility

- -
- - -

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

-
- -

See also

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