aboutsummaryrefslogtreecommitdiff
path: root/files/ar/web/javascript/reference/global_objects/object/constructor
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:41:15 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:41:15 -0500
commit4b1a9203c547c019fc5398082ae19a3f3d4c3efe (patch)
treed4a40e13ceeb9f85479605110a76e7a4d5f3b56b /files/ar/web/javascript/reference/global_objects/object/constructor
parent33058f2b292b3a581333bdfb21b8f671898c5060 (diff)
downloadtranslated-content-4b1a9203c547c019fc5398082ae19a3f3d4c3efe.tar.gz
translated-content-4b1a9203c547c019fc5398082ae19a3f3d4c3efe.tar.bz2
translated-content-4b1a9203c547c019fc5398082ae19a3f3d4c3efe.zip
initial commit
Diffstat (limited to 'files/ar/web/javascript/reference/global_objects/object/constructor')
-rw-r--r--files/ar/web/javascript/reference/global_objects/object/constructor/index.html152
1 files changed, 152 insertions, 0 deletions
diff --git a/files/ar/web/javascript/reference/global_objects/object/constructor/index.html b/files/ar/web/javascript/reference/global_objects/object/constructor/index.html
new file mode 100644
index 0000000000..140d95a732
--- /dev/null
+++ b/files/ar/web/javascript/reference/global_objects/object/constructor/index.html
@@ -0,0 +1,152 @@
+---
+title: Object.prototype.constructor
+slug: Web/JavaScript/Reference/Global_Objects/Object/constructor
+translation_of: Web/JavaScript/Reference/Global_Objects/Object/constructor
+---
+<div dir="rtl">{{JSRef}}</div>
+
+<p dir="rtl">بالرجوع إلى {{jsxref("Object")}}constructor ووظيفتها إنشاء حالات من الاوبجكت (الكائن) .نذكرك بأن قيمة الخصائص التي تشير إليها تلك الفانكشان تشير لنفسها ولا تشير إلى سلسة تحتوي على إسم الفانكشان القيمة تقرأ فقط قيم بدائية مثل <code>1</code>, <code>true</code> و <code>"test"</code>.</p>
+
+<h2 dir="rtl" id="الوصف">الوصف</h2>
+
+<p dir="rtl">جميع الاوبجكت ( مع بعض الاستثائات نشأت مع <code>Object.create(null)</code>  ) وستملك وقتها جميعا خاصية الـ <code>constructor </code>. اما  الكائنات المنشأة بدون إستخدام الكونستراكتور بشكل صريح ( مثل  object &amp; array literals )  ستملك أيضا خصائص الكونستركتور بشكل أساسي</p>
+
+<pre class="brush: js">var o = {};
+o.constructor === Object; // true
+
+var o = new Object;
+o.constructor === Object; // true
+
+var a = [];
+a.constructor === Array; // true
+
+var a = new Array;
+a.constructor === Array; // true
+
+var n = new Number(3);
+n.constructor === Number; // true
+</pre>
+
+<h2 dir="rtl" id="أمثلة">أمثلة</h2>
+
+<h3 dir="rtl" id="عرض_الكونستركتور_للأوبجكت">عرض الكونستركتور للأوبجكت</h3>
+
+<p dir="rtl">في المثال التالي قمنا بإنشاء بروتوتيب <code>Tree </code>و اوبجكت بإسم <code>theTree</code>  المثال هنا يعرض خصائص الـ<code>constructor</code> للكائن <code>theTree</code></p>
+
+<pre class="brush: js" dir="rtl">function Tree(name) {
+ this.name = name;
+}
+
+var theTree = new Tree('Redwood');
+console.log('theTree.constructor is ' + theTree.constructor);
+</pre>
+
+<p dir="rtl">عندما تقوم بكتابة الكود بعالية  ستحصل على النتيجة الاتية ليوضح لك أكثر  :-</p>
+
+<pre class="brush: js">theTree.constructor is function Tree(name) {
+ this.name = name;
+}
+</pre>
+
+<h3 dir="rtl" id="تغير_الكونستركتور_الخاص_بالاوبجكت">تغير الكونستركتور الخاص بالاوبجكت</h3>
+
+<p>The following example shows how to modify constructor value of generic objects. Only <code>true</code>, <code>1</code> and <code>"test"</code> will not be affected as they have read-only native constructors. This example shows that it is not always safe to rely on the <code>constructor</code> property of an object.</p>
+
+<pre class="brush:js">function Type () {}
+
+var types = [
+ new Array(),
+ [],
+ new Boolean(),
+ true, // remains unchanged
+ new Date(),
+ new Error(),
+ new Function(),
+ function () {},
+ Math,
+ new Number(),
+ 1, // remains unchanged
+ new Object(),
+ {},
+ new RegExp(),
+ /(?:)/,
+ new String(),
+ 'test' // remains unchanged
+];
+
+for (var i = 0; i &lt; types.length; i++) {
+ types[i].constructor = Type;
+ types[i] = [types[i].constructor, types[i] instanceof Type, types[i].toString()];
+}
+
+console.log(types.join('\n'));
+</pre>
+
+<p>This example displays the following output:</p>
+
+<pre class="brush: js">function Type() {},false,
+function Type() {},false,
+function Type() {},false,false
+function Boolean() {
+ [native code]
+},false,true
+function Type() {},false,Mon Sep 01 2014 16:03:49 GMT+0600
+function Type() {},false,Error
+function Type() {},false,function anonymous() {
+
+}
+function Type() {},false,function () {}
+function Type() {},false,[object Math]
+function Type() {},false,0
+function Number() {
+ [native code]
+},false,1
+function Type() {},false,[object Object]
+function Type() {},false,[object Object]
+function Type() {},false,/(?:)/
+function Type() {},false,/(?:)/
+function Type() {},false,
+function String() {
+ [native code]
+},false,test
+</pre>
+
+<h2 id="Specifications">Specifications</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES1')}}</td>
+ <td>{{Spec2('ES1')}}</td>
+ <td>Initial definition. Implemented in JavaScript 1.1.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES5.1', '#sec-15.2.4.1', 'Object.prototype.constructor')}}</td>
+ <td>{{Spec2('ES5.1')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES6', '#sec-object.prototype.constructor', 'Object.prototype.constructor')}}</td>
+ <td>{{Spec2('ES6')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-object.prototype.constructor', 'Object.prototype.constructor')}}</td>
+ <td>{{Spec2('ESDraft')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 dir="rtl" id="دعم_المتصفحات">دعم  المتصفحات</h2>
+
+<div>
+
+
+<p>{{Compat("javascript.builtins.Object.constructor")}}</p>
+</div>