fix(guide): simplify directory structure

This commit is contained in:
Mrugesh Mohapatra
2018-10-16 21:26:13 +05:30
parent f989c28c52
commit da0df12ab7
35752 changed files with 0 additions and 317652 deletions

View File

@@ -0,0 +1,37 @@
---
title: Add Methods After Inheritance
localeTitle: إضافة طرق بعد الوراثة
---
## إضافة طرق بعد الوراثة
### طريقة
تمامًا كما في المثال التالي ، يجب إنشاء مثيل جديد لكائن - `Dog` - ويجب تعيين `prototype` .
`function Bird() { }
Bird.prototype = Object.create(Animal.prototype);
Bird.prototype.constructor = Bird;
`
ثم يجب إضافة وظيفة جديدة - `bark()` - إلى نموذج الكلب.
### حل
`function Animal() { }
Animal.prototype.eat = function() { console.log("nom nom nom"); };
function Dog() { }
// Add your code below this line
Dog.prototype = Object.create(Animal.prototype);
Dog.prototype.constructor = Dog;
Dog.prototype.bark = function() {
console.log("Woof woof!");
};
// Add your code above this line
let beagle = new Dog();
beagle.eat(); // Should print "nom nom nom"
beagle.bark(); // Should print "Woof!"
`

View File

@@ -0,0 +1,76 @@
---
title: Change the Prototype to a New Object
localeTitle: تغيير النموذج إلى كائن جديد
---
## تغيير النموذج إلى كائن جديد
بدلا من إضافة كل خاصية نموذج واحد تلو الآخر مع `object.prototype.property` . يمكننا القيام بذلك أسهل بكثير من خلال وضع النموذج الأولي على كائن جديد. بهذه الطريقة تتم إضافة كل خصائص النموذج في وقت واحد.
## ملحوظة:
`Dog.prototype = {
property: value,
functionName: function(){
},
}
`
حاول الآن أن تحل التحدي!
## Spoiler-Alert الحل إلى الأمام!
## الحل 1:
`function Dog(name) {
this.name = name;
}
Dog.prototype = {
// Add your code below this line
numLegs: 2,
eat: function(){
console.log('nom nom nom');
},
describe: function(){
console.log("My name is " + this.name);
}
}
`
## شرح الشفرة:
نقوم بتعيين متغير النموذج إلى كائن جديد. ثم نعلن عن خاصية numLegs ونمنحه قيمة 2.
بعد ذلك نخلق الوظيفتين "تناول الطعام" و "وصف". الآن تذكر أن الدالات في الكائنات هي أساليب لها نفس الصيغة كخصائص. لديك اسم متبوعًا بقيمة. هذه القيمة هي الوظيفة والاسم هو اسم وظيفتك.
## الحل 2:
`function Dog(name) {
this.name = name;
}
Dog.prototype = {
// Add your code below this line
numLegs: 2,
eat(){
console.log('nom nom nom');
},
describe(){
console.log("My name is " + this.name);
}
};
`
## شرح الشفرة:
الشيء الوحيد المختلف بين هذا الحل والحل الأخير هو أننا قللنا بناء الجملة على وظائف "أكل" و "وصف". فعلنا ذلك عن طريق إزالة ":" وكلمة "وظيفة".
مع ES6 يسمح لنا القيام بذلك.
يمكنك أن تقرأ عنها هنا: [المرجع](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions)

View File

@@ -0,0 +1,17 @@
---
title: Create a Basic JavaScript Object
localeTitle: قم بإنشاء كائن JavaScript أساسي
---
## قم بإنشاء كائن JavaScript أساسي
### طريقة:
تتشابه هذه المشكلة إلى حد ما مع المثال المعطى. إعطاء كائن `dog` خاصيتين جديدتين - `name` و `numLegs` - وتعيينها إلى سلسلة ورقم ، على التوالي.
### حل:
`let dog = {
name: "George",
numLegs: 4
};
`

View File

@@ -0,0 +1,31 @@
---
title: Create a Method on an Object
localeTitle: إنشاء طريقة على كائن
---
## إنشاء طريقة على كائن
### طريقة:
يجب تهيئة وظيفة الكائنات داخل الكائن نفسه. يتم توضيح هذا في التعليمة البرمجية التالية.
`let obj = {
property1 = 1,
function1: function() {
//Code to be exectued
}
};
`
### حل:
`let dog = {
name: "Spot",
numLegs: 4,
sayLegs: function() {
return "This dog has " + dog.numLegs + " legs.";
}
};
dog.sayLegs();
`

View File

@@ -0,0 +1,18 @@
---
title: Define a Constructor Function
localeTitle: تحديد وظيفة منشئ
---
## تحديد وظيفة منشئ
### طريقة:
يجب كتابة الدالة `Dog()` بالتنسيق نفسه تمامًا مثل الدالة `Bird()` المعطاة في المثال. ببساطة استبدال `Bird` مع `Dog` لتمرير جميع حالات الاختبار.
### حل:
`function Dog() {
this.name = "Geogre",
this.color = "White",
this.numLegs = 4;
}
`

View File

@@ -0,0 +1,19 @@
---
title: Extend Constructors to Receive Arguments
localeTitle: تمديد البنائين لتلقي الحجج
---
## تمديد البنائين لتلقي الحجج
### طريقة:
مثلما في مثال `Bird()` ، يجب أن تقوم الدالة `Dog()` بجمع معلمتين - `name` `color` . يجب تهيئة الاسم واللون بعد ذلك داخل الدالة باستخدام `this` الكلمة الرئيسية. يتم تعيين الخاصية النهائية - `numLegs` إلى 4 كما لا تأخذ الدالة في معلمة numLegs.
### حل:
`function Dog(name, color) {
this.name = name;
this.color = color;
this.numLegs = 4;
}
let terrier = new Dog("George","White");
`

View File

@@ -0,0 +1,11 @@
---
title: Object Oriented Programming
localeTitle: البرمجة الشيئية
---
## البرمجة الشيئية
هذا هو كعب. [ساعد مجتمعنا على توسيعه](https://github.com/freecodecamp/guides/tree/master/src/pages/mathematics/quadratic-equations/index.md) .
[سيساعدك دليل النمط السريع هذا على ضمان قبول طلب السحب](https://github.com/freecodecamp/guides/blob/master/README.md) .
#### معلومات اكثر:

View File

@@ -0,0 +1,30 @@
---
title: Inherit Behaviors from a Supertype
localeTitle: وراثة السلوكيات من Supertype
---
## وراثة السلوكيات من Supertype
### طريقة
لتمرير هذا التحدي ببساطة خلق جديدة `duck` و `beagle` الكائنات باستخدام `Object.create()` طريقة رأينا في المثال التالي.
\`\` \`جافا سكريبت
السماح للحيوان = Object.create (Animal.prototype) ؛
`### Solution
`
جافا سكريبت
وظيفة الحيوان () {}
Animal.prototype = { منشئ: الحيوان ، أكل: وظيفة () { console.log ("nom nom nom")؛ } }؛
// أضف رمزك أدناه هذا السطر
السماح بطة = Object.create (Animal.prototype) ؛ // قم بتغيير هذا الخط let beagle = Object.create (Animal.prototype) ؛؛ // قم بتغيير هذا الخط
duck.eat ()؛ / / يجب طباعة "nom nom nom" beagle.eat ()؛ / / يجب طباعة "nom nom nom"
\`\` \`

View File

@@ -0,0 +1,33 @@
---
title: Iterate Over All Properties
localeTitle: تكرار جميع الممتلكات
---
## تكرار جميع الممتلكات
### طريقة
الأسلوب هو استخدام `for-in-loop` تكرار خلال كل خاصية في الكائن. داخل الحلقة ، `ownProps[]` إذا كان الخاصية خاصية `own-property` أو `prototype` ، ثم ضعها في `ownProps[]` أو صفيف `prototypeProps[]` . تذكر `push` الخصائص إلى كائن `beagle` وليس الكائن `Dog` لتمرير جميع حالات الاختبار.
### حل
`function Dog(name) {
this.name = name;
}
Dog.prototype.numLegs = 4;
let beagle = new Dog("Snoopy");
let ownProps = [];
let prototypeProps = [];
// Add your code below this line
for (let property in beagle) {
if(Dog.hasOwnProperty(property)) {
ownProps.push(property)
}
else {
prototypeProps.push(property)
}
}
`

View File

@@ -0,0 +1,20 @@
---
title: Make Code More Reusable with the this Keyword
localeTitle: جعل رمز أكثر قابلة لإعادة الاستخدام مع هذه الكلمة الرئيسية
---
## جعل رمز أكثر قابلة لإعادة الاستخدام مع هذه الكلمة الرئيسية
### طريقة:
هذا التحدي هو ببساطة إظهار قوة `this` الكلمة. يؤدي استبدال `dog.numLegs` بـ `this.numLegs` تعزيز الشفرة من خلال الرجوع إلى هذا الكائن مباشرة. يحتوي [developer.mozilla.org](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this) على العديد من الأمثلة لتحديد تأثيرات `this` الكلمة الرئيسية.
### حل:
`let dog = {
name: "Spot",
numLegs: 4,
sayLegs: function() {return "This dog has " + this.numLegs + " legs.";}
};
dog.sayLegs();
`

View File

@@ -0,0 +1,12 @@
---
title: Override Inherited Methods
localeTitle: تجاوز الأساليب الموروثة
---
## تجاوز الأساليب الموروثة
# حل
`Penguin.prototype.fly = function() {
return "Alas, this is a flightless bird.";
};
`

View File

@@ -0,0 +1,23 @@
---
title: Remember to Set the Constructor Property when Changing the Prototype
localeTitle: تذكر تعيين الخاصية منشئ عند تغيير "النموذج الأولي"
---
## تذكر تعيين الخاصية منشئ عند تغيير "النموذج الأولي"
* تذكر تعريف الخاصية منشئ عند تعيين نموذج أولي لكائن جديد.
# حل
`Dog.prototype = {
constructor: Dog, // Solution
numLegs: 2,
eat: function() {
console.log("nom nom nom");
},
describe: function() {
console.log("My name is " + this.name);
}
};
`

View File

@@ -0,0 +1,29 @@
---
title: Reset an Inherited Constructor Property
localeTitle: إعادة تعيين منشئ Conherrated الخاصية
---
## إعادة تعيين منشئ Conherrated الخاصية
### طريقة
تمت برمجة كائنات `duck` `beagle` لترث خصائص `supertypes` . للكتابة فوق هذين السطرين من التعليمات البرمجية يجب أن تتم كتابتها لتعيين المنشئين إلى المنشئين المطلوبين `Bird` و `Dog` . يوضح التعليمة البرمجية التالية كيف يمكن تحقيق ذلك.
`Bird.prototype.constructor = Bird;
`
### حل
`function Animal() { }
function Bird() { }
function Dog() { }
Bird.prototype = Object.create(Animal.prototype);
Dog.prototype = Object.create(Animal.prototype);
// Add your code below this line
Bird.prototype.constructor = Bird;
Dog.prototype.constructor = Dog;
let duck = new Bird();
let beagle = new Dog();
`

View File

@@ -0,0 +1,32 @@
---
title: Set the Child's Prototype to an Instance of the Parent
localeTitle: قم بتعيين Prototype الخاص بالطفل إلى مثيل من أصل
---
## قم بتعيين Prototype الخاص بالطفل إلى مثيل من أصل
### طريقة
لا يختلف هذا التحدي عن التحدي الأخير ، حيث يجب عليك إنشاء كائن يرث من النوع `supertype` . فقط هذه المرة سوف يرث `Dog` الفرعي نوع `Animal` الفائق. ببساطة إنشاء مثيل جديد من `Dog.prototype` مثل المثال التالي.
`Bird.prototype = Object.create(Animal.prototype);
`
### حل
`function Animal() { }
Animal.prototype = {
constructor: Animal,
eat: function() {
console.log("nom nom nom");
}
};
function Dog() { }
// Add your code below this line
Dog.prototype = Object.create(Animal.prototype);
let beagle = new Dog();
beagle.eat(); // Should print "nom nom nom"
`

View File

@@ -0,0 +1,23 @@
---
title: Understand Own Properties
localeTitle: فهم خصائص خاصة
---
## فهم خصائص خاصة
### طريقة:
في مثال الكود المعطى سترى مصفوفة جديدة `ownProps[]` intialised متبوعة بعلامة `for...in` العبارة للتكرار من خلال خصائص `duck` ثم استخدم عبارة `push()` لملء الصفيف الجديد. يجب اتباع نفس الطريقة لكائن `canary` .
ببساطة `duck` كائن `duck` في العبارة "for… in" مع كائن `canary` لتمرير جميع حالات الاختبار.
### حل:
`let canary = new Bird("Tweety");
let ownProps = [];
// Add your code below this line
for(let property in canary) {
if(canary.hasOwnProperty(property)) {
ownProps.push(property);
}
}
`

View File

@@ -0,0 +1,26 @@
---
title: Understand the Constructor Property
localeTitle: فهم خاصية منشئ
---
## فهم خاصية منشئ
### طريقة
ببساطة إنهاء وظيفة مثل ذلك المثال المعطى. استخدم عبارة `if-statement` لاختبار ما إذا كان `candidate` `Dog` أم لا.
### حل
`function Dog(name) {
this.name = name;
}
// Add your code below this line
function joinDogFraternity(candidate) {
if(candidate.constructor === Dog) {
return true;
}
else {
return false;
}
}
`

View File

@@ -0,0 +1,16 @@
---
title: Understand the Immediately Invoked Function Expression (IIFE)
localeTitle: فهم تعبير الدالة المستحثة فوراً (IIFE)
---
## فهم تعبير الدالة المستحثة فوراً (IIFE)
### طريقة
تطلب منك حالة الاختبار الأولى جعل الوظيفة مجهولة. للقيام بذلك ببساطة قم بإزالة اسم الدالة كما يظهر في المثال. بعد ذلك يجب أن تكون هذه الوظيفة ملفوفة في أقواس معقوفة مع مجموعة أخرى من الأقواس المتعرجة في النهاية للاتصال فوراً بالوظيفة.
### حل
`(function() {
console.log("A cozy nest is ready");
})();
`

View File

@@ -0,0 +1,17 @@
---
title: Understand the Prototype Chain
localeTitle: فهم سلسلة النموذج
---
## فهم سلسلة النموذج
### حل
يجب أن تُظهر الكود الخاص بك أن Object.prototype هو النموذج الأولي لـ Dog.prototype
\`\` \`جافا سكريبت وظيفة كلب (الاسم) { this.name = name؛ }
دع بيغل = كلب جديد ("سنوبي") ؛
Dog.prototype.isPrototypeOf (بيغل)؛ // => صحيح
// ثبّت الشفرة أدناه حتى يتم تقييمها إلى true Object.prototype.isPrototypeOf (Dog.prototype)؛ \`\` \`

View File

@@ -0,0 +1,9 @@
---
title: Understand Where an Objects Prototype Comes From
localeTitle: فهم أين يأتي النموذج الأولي للكائن من
---
## فهم أين يأتي النموذج الأولي للكائن من
هذا هو كعب. [ساعد مجتمعنا على توسيعه](https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/javascript-algorithms-and-data-structures/object-oriented-programming/understand-where-an-objects-prototype-comes-from/index.md) .
[سيساعدك دليل النمط السريع هذا على ضمان قبول طلب السحب](https://github.com/freecodecamp/guides/blob/master/README.md) .

View File

@@ -0,0 +1,20 @@
---
title: Use a Constructor to Create Objects
localeTitle: استخدم منشئ لإنشاء كائنات
---
## استخدم منشئ لإنشاء كائنات
### طريقة:
رأينا في التحدي الأخير كيفية إنشاء وظيفة منشئ. الآن يمكننا ببساطة استدعاء هذه الوظيفة لإنشاء كائن جديد مع خصائص محددة بالفعل في المنشئ. ببساطة تهيئة `hound` متغير جديد استدعاء منشئ `Dog()` .
### حل:
`function Dog() {
this.name = "Rupert";
this.color = "brown";
this.numLegs = 4;
}
// Add your code below this line
let hound = new Dog();
`

View File

@@ -0,0 +1,31 @@
---
title: Use a Mixin to Add Common Behavior Between Unrelated Objects
localeTitle: استخدم Mixin لإضافة سلوك شائع بين الكائنات غير المرتبطة
---
## استخدم Mixin لإضافة سلوك شائع بين الكائنات غير المرتبطة
### طريقة
تماما مثل وظيفة `flyMixin` ، يجب أن تكون وظيفة `glideMixin` جديدة لقبول كل من كائنات `bird` `boat` كمعلمة. قم بإنشاء هذه الوظيفة الجديدة باستخدام نفس صيغة الدالة `flyMixin` ثم قم باستدعاء الوظيفة على كلا العنصرين.
### حل
`let bird = {
name: "Donald",
numLegs: 2
};
let boat = {
name: "Warrior",
type: "race-boat"
};
// Add your code below this line
let glideMixin = function(obj) {
obj.glide = function() {
console.log("Gliding!");
}
};
glideMixin(bird);
glideMixin(boat);
`

View File

@@ -0,0 +1,42 @@
---
title: Use an IIFE to Create a Module
localeTitle: استخدم IIFE لإنشاء وحدة نمطية
---
## استخدم IIFE لإنشاء وحدة نمطية
### طريقة
يجب أن تكون ملفوفة في كلا `Mixin` 's في `funModule` جديدة لذا نقطة بداية esay للتعليق خارج الكود حتى الآن.
`/*let isCuteMixin = function(obj) {
obj.isCute = function() {
return true;
};
};
let singMixin = function(obj) {
obj.sing = function() {
console.log("Singing to an awesome tune");
};
};
*/
`
ثم أدناه ابدأ بكتابة كود `funModule` الجديد. داخل الوحدة النمطية الجديدة ، تحتاج إلى كتابة بيان إرجاع لإرجاع كتل التعليمات البرمجية `Mixin` . ما عليك سوى نسخ كل من الكود الأصلي لكتل `Mixin` إلى كود الوحدة الجديدة ، ولكن تذكر أن تفصل كل من المزيج مع `,`
### حل
`let funModule = (function() {
return {
isCuteMixin: function(obj) {
obj.isCute = function() {
return true;
};
},
singMixin: function(obj) {
obj.sing = function() {
console.log("Singing to an awesome tune");
};
}
}
})();
`

View File

@@ -0,0 +1,21 @@
---
title: Use Closure to Protect Properties Within an Object from Being Modified Externally
localeTitle: استخدم Closure لحماية الخصائص داخل كائن من التعديل الخارجي
---
## استخدم Closure لحماية الخصائص داخل كائن من التعديل الخارجي
### طريقة
تمامًا كما هو الحال في المثال المعطى ، بدلاً من تعريف متغير `weight` باستخدام `this` الكلمة الرئيسية ، يجب استخدام الكلمة المفتاحية `let` بإعلانها كمتغير خاص. بهذه الطريقة لا يمكن الوصول إليها إلا داخل وظيفة `Bird` . يجب إضافة طريقة `getWeight` داخل وظيفة `Bird` للوصول إلى متغير `weight` .
### حل
`function Bird() {
let weight = 15;
this.getWeight = function() {
return weight;
};
}
`

View File

@@ -0,0 +1,30 @@
---
title: Use Dot Notation to Access the Properties of an Object
localeTitle: استخدم Dot Notation للوصول إلى خصائص كائن
---
## استخدم Dot Notation للوصول إلى خصائص كائن
### طريقة:
ستقوم التعليمة البرمجية التالية ببساطة طباعة `property1` من كائن `obj` .
`let obj = {
property1 = 1,
property2 = 2
};
console.log(obj.property1);
`
باتباع هذا المنطق ، استخدم عملية `console.log` لطباعة كل من `property1` و `property2` على الشاشة.
### حل:
`let dog = {
name: "Spot",
numLegs: 4
};
// Add your code below this line
console.log(dog.name);
console.log(dog.numLegs);
`

View File

@@ -0,0 +1,35 @@
---
title: Use Inheritance So You Don't Repeat Yourself
localeTitle: استخدام الوراثة حتى لا تكرر نفسك
---
## استخدام الوراثة حتى لا تكرر نفسك
### حل
قم بإزالة طريقة "تناول الطعام" من Cat.prototype و Bear.prototype وأضفها إلى Animal.prototype.
`function Cat(name) {
this.name = name;
};
Cat.prototype = {
constructor: Cat
};
function Bear(name) {
this.name = name;
};
Bear.prototype = {
constructor: Bear
};
function Animal() { };
Animal.prototype = {
constructor: Animal,
eat: function() {
console.log("nom nom nom");
}
};
`

View File

@@ -0,0 +1,28 @@
---
title: Use Prototype Properties to Reduce Duplicate Code
localeTitle: استخدم خصائص النموذج لتخفيض قانون مكرر
---
## استخدم خصائص النموذج لتخفيض قانون مكرر
### طريقة:
تسمح لك خاصية `prototype` بإضافة خصائص جديدة إلى مُنشئ كائن من خارج كتلة التعليمات البرمجية الأصلية. كما تسمح لك خاصية النموذج الأولي بإضافة وظائف جديدة إلى مُنشئ الكائنات. يوضح التعليمة البرمجية التالية كيفية استخدام `.prototype` على كائن لإنشاء خاصية جديدة في المُنشئ.
#### مثال:
`Obj.prototype.newProperty = "New Property!";
`
باستخدام هذا المنطق ، ببساطة إنشاء خاصية `prototype` جديد لـ `numLegs` . يمكن تمرير حالات الاختبار عن طريق استبدال كائن `Bird` بكائن `Dog` في المثال المعطى - `Bird.prototype.numLegs = 2;`
### حل:
`function Dog(name) {
this.name = name;
}
Dog.prototype.numLegs = 4;
// Add your code above this line
let beagle = new Dog("Snoopy");
`

View File

@@ -0,0 +1,29 @@
---
title: Verify an Object's Constructor with instanceof
localeTitle: تحقق من Constructor كائن مع instanceof
---
## تحقق من Constructor كائن مع instanceof
### طريقة:
تماماً كما في التحدي الأخير ، قم بإنشاء كائن جديد - `myHouse` - باستخدام المُنشئ المعطى.
#### مثال:
`let hound = new Dog();
`
تذكر أن تعطي الدالة `House` معلمة لتهيئة عدد الغرف. ثم ببساطة استدعاء العامل `instanceof` للعودة حقيقية على منزلك الجديد.
### حل:
`/* jshint expr: true */
function House(numBedrooms) {
this.numBedrooms = numBedrooms;
}
// Add your code below this line
let myHouse = new House(5);
myHouse instanceof House;
`