fix: converted single to triple backticks11 (#36238)

This commit is contained in:
Randell Dawson
2019-06-20 13:42:13 -07:00
committed by Tom
parent 397014136e
commit 54d303ce1f
75 changed files with 1673 additions and 1430 deletions

View File

@@ -8,16 +8,18 @@ localeTitle: Map.prototype.size
## بناء الجملة
`myMap.size();
`
```javascript
myMap.size();
```
## مثال
`const myMap = new Map();
myMap.set('foo',1);
myMap.set('bar',2);
myMap.set('baz',3);
myMap.size(); // 3
`
```javascript
const myMap = new Map();
myMap.set('foo',1);
myMap.set('bar',2);
myMap.set('baz',3);
myMap.size(); // 3
```

View File

@@ -8,19 +8,21 @@ localeTitle: Map.prototype.values
## بناء الجملة
`myMap.values()
`
```javascript
myMap.values()
```
## مثال
`const myMap = new Map();
myMap.set('foo',1);
myMap.set('bar',2);
myMap.set('baz',3);
const iterator = myMap.values();
console.log(iterator.next().value); // 1
console.log(iterator.next().value); // 2
console.log(iterator.next().value); // 3
`
```javascript
const myMap = new Map();
myMap.set('foo',1);
myMap.set('bar',2);
myMap.set('baz',3);
const iterator = myMap.values();
console.log(iterator.next().value); // 1
console.log(iterator.next().value); // 2
console.log(iterator.next().value); // 3
```

View File

@@ -10,11 +10,12 @@ localeTitle: الرياضيات
يوضح المثال التالي كيفية استخدام كائن `Math` لكتابة دالة تقوم بحساب مساحة دائرة:
`function calculateCircleArea(radius) {
return Math.PI * Math.pow(radius, 2);
}
calculateCircleArea(1); // 3.141592653589793
`
```javascript
function calculateCircleArea(radius) {
return Math.PI * Math.pow(radius, 2);
}
calculateCircleArea(1); // 3.141592653589793
```
### موارد آخرى

View File

@@ -8,11 +8,12 @@ localeTitle: الرياضيات Ceil
### أمثلة
`Math.ceil(0.1) // 1
Math.ceil(1.3) // 2
Math.ceil(-0.9) // -0
Math.ceil(-1.5) // -1
`
```javascript
Math.ceil(0.1) // 1
Math.ceil(1.3) // 2
Math.ceil(-0.9) // -0
Math.ceil(-1.5) // -1
```
### معلومات اكثر:

View File

@@ -8,12 +8,13 @@ localeTitle: الطابق الرياضيات
### أمثلة
`Math.floor(0.9) // 0
Math.floor(1.3) // 1
Math.floor(0.5) // 0
Math.floor(-0.9) // -1
Math.floor(-1.3) // -2
`
```javascript
Math.floor(0.9) // 0
Math.floor(1.3) // 1
Math.floor(0.5) // 0
Math.floor(-0.9) // -1
Math.floor(-1.3) // -2
```
### معلومات اكثر:

View File

@@ -10,8 +10,9 @@ localeTitle: الرياضيات ماكس
### بناء الجملة
`Math.max(value1, value2, value3, ...);
`
```js
Math.max(value1, value2, value3, ...);
```
### المعلمات
@@ -25,27 +26,31 @@ localeTitle: الرياضيات ماكس
_الأرقام كمعلمات_
`Math.max(4, 13, 27, 0, -5); // returns 27
`
```js
Math.max(4, 13, 27, 0, -5); // returns 27
```
_معلمة غير صالحة_
`Math.max(4, 13, 27, 'eight', -5); // returns NaN
`
```js
Math.max(4, 13, 27, 'eight', -5); // returns NaN
```
_صفيف كمعلمة ، استخدام السبريد (…)_
`let numbers = [4, 13, 27, 0, -5];
Math.max(...numbers); // returns 27
`
```js
let numbers = [4, 13, 27, 0, -5];
Math.max(...numbers); // returns 27
```
_صفيف كمعلمة ، باستخدام تطبيق_
`let numbers = [4, 13, 27, 0, -5];
Math.max.apply(null, numbers); // returns 27
`
```js
let numbers = [4, 13, 27, 0, -5];
Math.max.apply(null, numbers); // returns 27
```
#### معلومات اكثر:

View File

@@ -8,9 +8,10 @@ localeTitle: الرياضيات مين
يمكنك تمرير أي عدد من الحجج.
`Math.min(7, 2, 9, -6);
// returns -6
`
```javascript
Math.min(7, 2, 9, -6);
// returns -6
```
#### معلومات اكثر:

View File

@@ -10,8 +10,9 @@ localeTitle: الرياضيات PI
## أمثلة
`Math.PI \\ 3.141592653589793
`
```js
Math.PI \\ 3.141592653589793
```
#### معلومات اكثر:

View File

@@ -14,12 +14,13 @@ localeTitle: الرياضيات الأسرى
#### أمثلة
`Math.pow(5, 2); // 25
Math.pow(7, 4); // 2401
Math.pow(9, 0.5); // 3
Math.pow(-8, 2); // 64
Math.pow(-4, 3); // -64
`
```js
Math.pow(5, 2); // 25
Math.pow(7, 4); // 2401
Math.pow(9, 0.5); // 3
Math.pow(-8, 2); // 64
Math.pow(-4, 3); // -64
```
#### معلومات اكثر:

View File

@@ -12,10 +12,11 @@ localeTitle: الرياضيات عشوائي
#### مثال
`function randomInRange(min, max) {
return Math.random() * (max - min) + min;
}
`
```js
function randomInRange(min, max) {
return Math.random() * (max - min) + min;
}
```
#### معلومات اكثر:

View File

@@ -16,12 +16,13 @@ localeTitle: الرياضيات Sqrt
#### أمثلة
`Math.sqrt(25); // 5
Math.sqrt(169); // 13
Math.sqrt(3); // 1.732050807568
Math.sqrt(1); // 1
Math.sqrt(-5); // NaN
`
```js
Math.sqrt(25); // 5
Math.sqrt(169); // 13
Math.sqrt(3); // 1.732050807568
Math.sqrt(1); // 1
Math.sqrt(-5); // NaN
```
#### معلومات اكثر:

View File

@@ -10,12 +10,13 @@ localeTitle: Math Trunc
### أمثلة
`Math.trunc(0.1) // 0
Math.trunc(1.3) // 1
Math.trunc(-0.9) // -0
Math.trunc(-1.5) // -1
Math.trunc('foo') // NaN
`
```javascript
Math.trunc(0.1) // 0
Math.trunc(1.3) // 1
Math.trunc(-0.9) // -0
Math.trunc(-1.5) // -1
Math.trunc('foo') // NaN
```
### معلومات اكثر:

View File

@@ -26,25 +26,26 @@ A [Boolean](https://guide.freecodecamp.org/javascript/booleans) تشير إلى
## أمثلة
`Number.isInteger(0); // true
Number.isInteger(-0); // true
Number.isInteger(1); // true
Number.isInteger(2); // true
Number.isInteger(-100001); // true
Number.isInteger(999999999999999999999999); // true
Number.isInteger(0.1); // false
Number.isInteger(0.3); // false
Number.isInteger(Math.PI); // false
Number.isInteger(NaN); // false
Number.isInteger(Infinity); // false
Number.isInteger(-Infinity); // false
Number.isInteger('10'); // false
Number.isInteger(true); // false
Number.isInteger(false); // false
Number.isInteger([1]); // false
`
```
Number.isInteger(0); // true
Number.isInteger(-0); // true
Number.isInteger(1); // true
Number.isInteger(2); // true
Number.isInteger(-100001); // true
Number.isInteger(999999999999999999999999); // true
Number.isInteger(0.1); // false
Number.isInteger(0.3); // false
Number.isInteger(Math.PI); // false
Number.isInteger(NaN); // false
Number.isInteger(Infinity); // false
Number.isInteger(-Infinity); // false
Number.isInteger('10'); // false
Number.isInteger(true); // false
Number.isInteger(false); // false
Number.isInteger([1]); // false
```
#### معلومات اكثر:

View File

@@ -16,8 +16,9 @@ localeTitle: كائن التعيين
**بناء الجملة**
`Object.assign(targetObject, ...sourceObject)
`
```javascript
Object.assign(targetObject, ...sourceObject)
```
**قيمة الإرجاع**
@@ -27,33 +28,36 @@ localeTitle: كائن التعيين
_تعديل ونسخ targetObject_
`let obj = {name: 'Dave', age: 30};
let objCopy = Object.assign(obj, {coder: true});
console.log(obj); // returns { name: 'Dave', age: 30, coder: true }
console.log(objCopy); // returns { name: 'Dave', age: 30, coder: true }
`
```javascript
let obj = {name: 'Dave', age: 30};
let objCopy = Object.assign(obj, {coder: true});
console.log(obj); // returns { name: 'Dave', age: 30, coder: true }
console.log(objCopy); // returns { name: 'Dave', age: 30, coder: true }
```
_نسخ targetObject بدون تعديل_
`let obj = {name: 'Dave', age: 30};
let objCopy = Object.assign({}, obj, {coder: true});
console.log(obj); // returns { name: 'Dave', age: 30 }
console.log(objCopy); // returns { name: 'Dave', age: 30, coder: true }
`
```javascript
let obj = {name: 'Dave', age: 30};
let objCopy = Object.assign({}, obj, {coder: true});
console.log(obj); // returns { name: 'Dave', age: 30 }
console.log(objCopy); // returns { name: 'Dave', age: 30, coder: true }
```
ائنات ذات خصائص مماثلة_
`let obj = {name: 'Dave', age: 30, favoriteColor: 'blue'};
let objCopy = Object.assign({}, obj, {coder: true, favoriteColor: 'red'});
console.log(obj); // returns { name: 'Dave', age: 30, favoriteColor: 'blue' }
console.log(objCopy); // { name: 'Dave', age: 30, favoriteColor: 'red', coder: true }
`
```javascript
let obj = {name: 'Dave', age: 30, favoriteColor: 'blue'};
let objCopy = Object.assign({}, obj, {coder: true, favoriteColor: 'red'});
console.log(obj); // returns { name: 'Dave', age: 30, favoriteColor: 'blue' }
console.log(objCopy); // { name: 'Dave', age: 30, favoriteColor: 'red', coder: true }
```
#### معلومات اكثر:

View File

@@ -10,21 +10,23 @@ localeTitle: Object Destructuring
### الواجب الأساسي
`var userInfo = {name: 'neel', age: 22};
var {name, age} = userInfo;
console.log(name); // neel
console.log(age); // 22
`
```
var userInfo = {name: 'neel', age: 22};
var {name, age} = userInfo;
console.log(name); // neel
console.log(age); // 22
```
### التنازل دون تصريح
يمكن تعيين متغير قيمته مع التدمير المنفصل عن تصريحه.
`var name, age;
({name, age} = {name: 'neel', age: 22});
`
```
var name, age;
({name, age} = {name: 'neel', age: 22});
```
> و `( .. )` حول جملة الواجب هو بناء جملة مطلوب عند استخدام التعيين الحرفي كائن الهدف دون تصريح.
>
@@ -36,22 +38,24 @@ localeTitle: Object Destructuring
يمكن فك أي خاصية من أحد الكائنات وتخصيصها لمتغير باسم مختلف عن خاصية الكائن.
`var userInfo = {a: 'neel', b: 22};
var {a: name, b: bar} = userInfo;
console.log(name); // neel
console.log(bar); // 22
`
```
var userInfo = {a: 'neel', b: 22};
var {a: name, b: bar} = userInfo;
console.log(name); // neel
console.log(bar); // 22
```
### قيم افتراضية
متغير يمكن تعيين الافتراضي، في حالة أن القيمة تفكيك من الكائن هو `undefined` .
`var {name = 'ananonumys', age = 20} = {name: 'neel'};
console.log(name); // neel
console.log(age); // 20
`
```
var {name = 'ananonumys', age = 20} = {name: 'neel'};
console.log(name); // neel
console.log(age); // 20
```
### تعيين أسماء المتغيرات الجديدة وتوفير القيم الافتراضية
@@ -60,132 +64,139 @@ localeTitle: Object Destructuring
1. تفكيكها من كائن وتعيين لمتغير مع اسم مختلف و
2. تعيين قيمة افتراضية في حالة القيمة غير `undefined` غير `undefined` .
`var {a:name = 'ananonumys', b:age = 20} = {age: 22};
console.log(name); // ananonumys
console.log(age); // 22
`
```
var {a:name = 'ananonumys', b:age = 20} = {age: 22};
console.log(name); // ananonumys
console.log(age); // 22
```
### إعداد القيمة الافتراضية لعلامة دالة
#### ES5 الإصدار
`function getUserInfo(data) {
data = data === undefined ? {} : data;
var name = data.name === undefined ? 'ananonumys' : data.name;
var age = data.age === undefined ? 20 : data.age;
var location = data.location === undefined ? 'india' : data.location;
console.log(name, age, location);
// print user data
}
getUserInfo({
name: 'neel',
age: 22,
location: 'canada'
});
`
```
function getUserInfo(data) {
data = data === undefined ? {} : data;
var name = data.name === undefined ? 'ananonumys' : data.name;
var age = data.age === undefined ? 20 : data.age;
var location = data.location === undefined ? 'india' : data.location;
console.log(name, age, location);
// print user data
}
getUserInfo({
name: 'neel',
age: 22,
location: 'canada'
});
```
#### نسخة ES2015
`function getUserInfo({name = 'ananonumys', age = 20, location = 'india'} = {}) {
console.log(name, age, location);
// print user data
}
getUserInfo({
name: 'neel',
age: 22,
location: 'canada'
});
`
```
function getUserInfo({name = 'ananonumys', age = 20, location = 'india'} = {}) {
console.log(name, age, location);
// print user data
}
getUserInfo({
name: 'neel',
age: 22,
location: 'canada'
});
```
> في توقيع الدالة `getUserInfo` أعلاه ، يتم تعيين الجانب الأيسر المدمر إلى كائن حرفي فارغ على الجانب الأيمن: `{name = 'ananonumys', age = 20, location = 'india'} = {}` . كان بإمكانك أيضًا كتابة الوظيفة بدون تعيين الجانب الأيمن. ومع ذلك ، إذا قمت `getUserInfo()` تعيين الجانب الأيمن ، ستبحث الدالة عن وسيطة واحدة على الأقل `getUserInfo()` عند استدعاء ، بينما في شكلها الحالي ، يمكنك ببساطة استدعاء `getUserInfo()` دون توفير أي معلمات. يفيد التصميم الحالي إذا كنت تريد أن تكون قادرًا على استدعاء الدالة دون توفير أي معلمات ، يمكن أن يكون الآخر مفيدًا عندما تريد التأكد من تمرير كائن إلى الوظيفة.
### كائن متداخل ومجموعة المدمر
`var metadata = {
title: 'Scratchpad',
translations: [
{
locale: 'de',
localization_tags: [],
last_edit: '2014-04-14T08:43:37',
url: '/de/docs/Tools/Scratchpad',
title: 'JavaScript-Umgebung'
}
],
url: '/en-US/docs/Tools/Scratchpad'
};
var {title: englishTitle, translations: [{title: localeTitle}]} = metadata;
console.log(englishTitle); // "Scratchpad"
console.log(localeTitle); // "JavaScript-Umgebung"
`
```
var metadata = {
title: 'Scratchpad',
translations: [
{
locale: 'de',
localization_tags: [],
last_edit: '2014-04-14T08:43:37',
url: '/de/docs/Tools/Scratchpad',
title: 'JavaScript-Umgebung'
}
],
url: '/en-US/docs/Tools/Scratchpad'
};
var {title: englishTitle, translations: [{title: localeTitle}]} = metadata;
console.log(englishTitle); // "Scratchpad"
console.log(localeTitle); // "JavaScript-Umgebung"
```
### للتكرار والتدمير
`var people = [
{
name: 'Mike Smith',
family: {
mother: 'Jane Smith',
father: 'Harry Smith',
sister: 'Samantha Smith'
},
age: 35
},
{
name: 'Tom Jones',
family: {
mother: 'Norah Jones',
father: 'Richard Jones',
brother: 'Howard Jones'
},
age: 25
}
];
for (var {name: n, family: {father: f}} of people) {
console.log('Name: ' + n + ', Father: ' + f);
}
// "Name: Mike Smith, Father: Harry Smith"
// "Name: Tom Jones, Father: Richard Jones"
`
```
var people = [
{
name: 'Mike Smith',
family: {
mother: 'Jane Smith',
father: 'Harry Smith',
sister: 'Samantha Smith'
},
age: 35
},
{
name: 'Tom Jones',
family: {
mother: 'Norah Jones',
father: 'Richard Jones',
brother: 'Howard Jones'
},
age: 25
}
];
for (var {name: n, family: {father: f}} of people) {
console.log('Name: ' + n + ', Father: ' + f);
}
// "Name: Mike Smith, Father: Harry Smith"
// "Name: Tom Jones, Father: Richard Jones"
```
### تفريغ الحقول من الكائنات التي تم تمريرها كمعلمة دالة
`function userId({id}) {
return id;
}
function whois({displayName, fullName: {firstName: name}}) {
console.log(displayName + ' is ' + name);
}
var user = {
id: 42,
displayName: 'jdoe',
fullName: {
firstName: 'John',
lastName: 'Doe'
}
};
console.log('userId: ' + userId(user)); // "userId: 42"
whois(user); // "jdoe is John"
`
```
function userId({id}) {
return id;
}
function whois({displayName, fullName: {firstName: name}}) {
console.log(displayName + ' is ' + name);
}
var user = {
id: 42,
displayName: 'jdoe',
fullName: {
firstName: 'John',
lastName: 'Doe'
}
};
console.log('userId: ' + userId(user)); // "userId: 42"
whois(user); // "jdoe is John"
```
هذا unpacks `id` و `displayName` و `firstName` من كائن المستخدم `firstName` .
### أسماء خصائص كائن محسوب و destructuring
`let key = 'z';
let {[key]: foo} = {z: 'bar'};
console.log(foo); // "bar"
`
```
let key = 'z';
let {[key]: foo} = {z: 'bar'};
console.log(foo); // "bar"
```
انظر أيضا: **Object Destructuring** | [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Object_destructuring)

View File

@@ -12,8 +12,9 @@ localeTitle: تجميد الكائن
### بناء الجملة
`Object.freeze(obj)
`
```javascript
Object.freeze(obj)
```
### المعلمات
@@ -31,35 +32,36 @@ localeTitle: تجميد الكائن
### مثال
`// Create your object
let person = {
name: 'Johnny',
age: 23,
guild: 'Army of Darkness',
hobbies: ['music', 'gaming', 'rock climbing']
}
// Modify your object
person.name = 'John'
person.age = 24
person.hobbies.splice(1,1)
delete person.guild
// Verify your object has been modified
console.log(person) // { name: 'John', age: 24, hobbies: ['music', 'rock climbing']
// Freeze your object
Object.freeze(person)
// Verify that your object can no longer be modified
person.name = 'Johnny' // fails silently
person.age = 23 // fails silently
console.log(person) // { name: 'John', age: 24, hobbies: ['music', 'rock climbing']
// The freeze is "shallow" and nested objects (including arrays) can still be modified
person.hobbies.push('basketball')
consol.log(person.hobbies) // ['music', 'rock climbing', 'basketball']
`
```javascript
// Create your object
let person = {
name: 'Johnny',
age: 23,
guild: 'Army of Darkness',
hobbies: ['music', 'gaming', 'rock climbing']
}
// Modify your object
person.name = 'John'
person.age = 24
person.hobbies.splice(1,1)
delete person.guild
// Verify your object has been modified
console.log(person) // { name: 'John', age: 24, hobbies: ['music', 'rock climbing']
// Freeze your object
Object.freeze(person)
// Verify that your object can no longer be modified
person.name = 'Johnny' // fails silently
person.age = 23 // fails silently
console.log(person) // { name: 'John', age: 24, hobbies: ['music', 'rock climbing']
// The freeze is "shallow" and nested objects (including arrays) can still be modified
person.hobbies.push('basketball')
consol.log(person.hobbies) // ['music', 'rock climbing', 'basketball']
```
#### معلومات اكثر:

View File

@@ -8,24 +8,26 @@ localeTitle: الكائن هو المجمدة
#### **بناء الجملة**
`Object.isFrozen(obj)
`
```javascript
Object.isFrozen(obj)
```
**فمثلا:**
`var foods = {
grain : "wheat",
dairy : "milk",
vegetable : "carrot",
fruit : "grape"
};
var frozenFoods = Object.freeze(foods);
var areMyFoodsFrozen = Object.isFrozen(frozenFoods);
\\ returns true
`
```javascript
var foods = {
grain : "wheat",
dairy : "milk",
vegetable : "carrot",
fruit : "grape"
};
var frozenFoods = Object.freeze(foods);
var areMyFoodsFrozen = Object.isFrozen(frozenFoods);
\\ returns true
```
تذكر ، **لا يمكن أن** يكون له خاصية مجمدة تغير خصائصها.

View File

@@ -24,21 +24,22 @@ localeTitle: Object.prototype.hasOwnProperty
باستخدام **hasOwnProperty ()** لاختبار ما إذا كانت خاصية موجودة أم لا في كائن محدد:
`var course = {
name: 'freeCodeCamp',
feature: 'is awesome',
}
var student = {
name: 'enthusiastic student',
}
course.hasOwnProperty('name'); // returns true
course.hasOwnProperty('feature'); // returns true
student.hasOwnProperty('name'); // returns true
student.hasOwnProperty('feature'); // returns false
`
```js
var course = {
name: 'freeCodeCamp',
feature: 'is awesome',
}
var student = {
name: 'enthusiastic student',
}
course.hasOwnProperty('name'); // returns true
course.hasOwnProperty('feature'); // returns true
student.hasOwnProperty('name'); // returns true
student.hasOwnProperty('feature'); // returns false
```
#### الروابط

View File

@@ -8,13 +8,14 @@ localeTitle: وعد رفض
سيسمح لك تسلسل وظيفة catch في نهاية المتصل Promise بالتقاط حالة الخطأ.
`promiseCallingFunction(paramList)
.then( ... )
...
.then( ... )
.catch( function(err) { // catch function
/*
* this is where you can access the reason for the rejection
*/
});
`
```javascript
promiseCallingFunction(paramList)
.then( ... )
...
.then( ... )
.catch( function(err) { // catch function
/*
* this is where you can access the reason for the rejection
*/
});
```

View File

@@ -12,32 +12,35 @@ localeTitle: وعد بالقرار
يمكن أن تكون "القيمة" لدالة التصميم هي أنواع جافا سكريبت الأساسية ، أو المصفوفات ، أو الكائنات.
`Promise.resolve('success'); // string
Promise.resolve([2, 3, 5]); // array
Promise.resolve({name: 'John', age: '43'}); // object
`
```javascript
Promise.resolve('success'); // string
Promise.resolve([2, 3, 5]); // array
Promise.resolve({name: 'John', age: '43'}); // object
```
A "thenable" هي دالة تأخذ وظيفتي رد اتصال كمعلمات. يمكنك استخدام المعلمة الأولى لتشغيل عملية إكمال ناجحة ، والثاني لإرجاع خطأ في Promise.
`thenableFunction = {then: function(onSuccesss, onFailure) {
if (condition === 'success') {
onSuccess(paramList); // success condition
} else {
onFailure(paramList); // error condition
}
}
}
Promise.resolve(thenableFunction);
`
```javascript
thenableFunction = {then: function(onSuccesss, onFailure) {
if (condition === 'success') {
onSuccess(paramList); // success condition
} else {
onFailure(paramList); // error condition
}
}
}
Promise.resolve(thenableFunction);
```
سيؤدي تسلسل وظيفة ثم إلى متصل الوعد إلى الوصول إلى نتيجة `Promise.resolve` .
`promiseCallingFunction(paramList)
.then(function(value) {
/*
* this is where you get access to the value
* returned by a promise on successful completion
*/
});
`
```javascript
promiseCallingFunction(paramList)
.then(function(value) {
/*
* this is where you get access to the value
* returned by a promise on successful completion
*/
});
```

View File

@@ -8,27 +8,29 @@ localeTitle: RegExp.prototype.test
## أمثلة
`let str = 'freeCodeCamp';
let regEx = /Code/;
let result = regEx.test(str);
console.log(result); // prints true
`
```javascript
let str = 'freeCodeCamp';
let regEx = /Code/;
let result = regEx.test(str);
console.log(result); // prints true
```
**ملاحظة:** التعبيرات العادية حساسة لحالة الأحرف. سيظهر المثال أعلاه `false` إذا كان `regEx` `/code/` بدلاً من `/Code/` . لجعل التعبير العادي غير حساس لحالة الأحرف ، يجب عليك إضافة علامة `i` إلى التعبير العادي.
`let str = 'freeCodeCamp';
let regEx = /code/;
let result = regEx.test(str);
console.log(result); // prints false
// Include the 'i' flag.
regEx = /code/i;
result = regEx.test(str);
console.log(result); // prints true
`
```javascript
let str = 'freeCodeCamp';
let regEx = /code/;
let result = regEx.test(str);
console.log(result); // prints false
// Include the 'i' flag.
regEx = /code/i;
result = regEx.test(str);
console.log(result); // prints true
```
#### معلومات اكثر:

View File

@@ -8,14 +8,16 @@ localeTitle: String.prototype.endsWith
### فمثلا
`let str = "Hello world";
let bool = str.endsWith("ld") // true
bool = str.endsWith("llo") // false
`
```js
let str = "Hello world";
let bool = str.endsWith("ld") // true
bool = str.endsWith("llo") // false
```
يمكن أن تقبل هذه الطريقة أيضًا معلمة أخرى ، وهي `length` الذي يحدد قبل أي حرف للبحث في السلسلة.
`let str = "Hello world";
let bool = str.endsWith("ld", 5) // false, it's the same as "Hello".endsWith("ld")
bool = str.endsWith("llo", 5) // true, it's the same as "Hello".endsWith("llo")
`
```js
let str = "Hello world";
let bool = str.endsWith("ld", 5) // false, it's the same as "Hello".endsWith("ld")
bool = str.endsWith("llo", 5) // true, it's the same as "Hello".endsWith("llo")
```

View File

@@ -14,8 +14,9 @@ localeTitle: String.prototype.includes
**بناء الجملة**
`string.includes(searchString[, position])
`
```js
string.includes(searchString[, position])
```
**المعلمات**
@@ -23,30 +24,35 @@ localeTitle: String.prototype.includes
**أمثلة**
`let string = "Roses are red, violets are blue.";
string.includes('red'); // returns true
`
```js
let string = "Roses are red, violets are blue.";
`let string = "Roses are red, violets are blue.";
string.includes('Red'); // returns false
`
string.includes('red'); // returns true
```
`let string = "Roses are red, violets are blue.";
string.includes('red',12); // returns false because 'red' starts at position 9, and our search begins at position 12.
`
```javascript
let string = "Roses are red, violets are blue.";
`let string = "Roses are red, violets are blue.";
string.includes('blue',12); // returns true because 'blue' starts after our search begins at position 12.
`
string.includes('Red'); // returns false
```
`let string = "Roses are red, violets are blue.";
string.includes('violets are blue'); // returns true
`
```javascript
let string = "Roses are red, violets are blue.";
string.includes('red',12); // returns false because 'red' starts at position 9, and our search begins at position 12.
```
```javascript
let string = "Roses are red, violets are blue.";
string.includes('blue',12); // returns true because 'blue' starts after our search begins at position 12.
```
```javascript
let string = "Roses are red, violets are blue.";
string.includes('violets are blue'); // returns true
```
#### معلومات اكثر:

View File

@@ -8,8 +8,9 @@ localeTitle: String.prototype.indexOf
**بناء الجملة**
`str.indexOf(searchValue[, fromIndex])
`
```javascript
str.indexOf(searchValue[, fromIndex])
```
### المعلمات
@@ -24,17 +25,18 @@ localeTitle: String.prototype.indexOf
### أمثلة
`'Blue Whale'.indexOf('Blue'); // returns 0
'Blue Whale'.indexOf('Blute'); // returns -1
'Blue Whale'.indexOf('Whale', 0); // returns 5
'Blue Whale'.indexOf('Whale', 5); // returns 5
'Blue Whale'.indexOf('Whale', 7); // returns -1
'Blue Whale'.indexOf(''); // returns 0
'Blue Whale'.indexOf('', 9); // returns 9
'Blue Whale'.indexOf('', 10); // returns 10
'Blue Whale'.indexOf('', 11); // returns 10
'Blue Whale'.indexOf('blue'); // returns -1
`
```javascript
'Blue Whale'.indexOf('Blue'); // returns 0
'Blue Whale'.indexOf('Blute'); // returns -1
'Blue Whale'.indexOf('Whale', 0); // returns 5
'Blue Whale'.indexOf('Whale', 5); // returns 5
'Blue Whale'.indexOf('Whale', 7); // returns -1
'Blue Whale'.indexOf(''); // returns 0
'Blue Whale'.indexOf('', 9); // returns 9
'Blue Whale'.indexOf('', 10); // returns 10
'Blue Whale'.indexOf('', 11); // returns 10
'Blue Whale'.indexOf('blue'); // returns -1
```
### معلومات اكثر:

View File

@@ -12,26 +12,28 @@ localeTitle: String.prototype.split
أمثلة:
`// We have a regular string
"Hello. I am a string. You can separate me."
// Let's use the split function to separate the string by the period character:
"Hello. I am a string. You can separate me.".split(".");
// output is [ "Hello", " I am a string", " You can separate me", "" ]
`
```js
// We have a regular string
"Hello. I am a string. You can separate me."
// Let's use the split function to separate the string by the period character:
"Hello. I am a string. You can separate me.".split(".");
// output is [ "Hello", " I am a string", " You can separate me", "" ]
```
بما أننا استخدمنا النقطة ( `.` ) _كسلسلة فاصلة_ ، فإن السلاسل في صفيف الخرج لا تحتوي على الفترة الموجودة فيها ؛ _لا تتضمن_ سلاسل فصل الإخراج _سلسلة سلسلة فاصل الإدخال نفسه_ .
ليس من الضروري أن يكون _فاصل السلسلة_ حرفًا واحدًا ، يمكن أن يكون أي سلسلة أخرى:
`"Hello... I am another string... keep on learning!".split("...");
// output is [ "Hello", " I am another string", " keep on learning!" ]
const names = "Kratos- Atreus- Freya- Hela- Thor- Odin";
// notice separator is a dash and a space
names.split("- ");
// output is [ "Kratos", "Atreus", "Freya", "Hela", "Thor", "Odin" ]
`
```js
"Hello... I am another string... keep on learning!".split("...");
// output is [ "Hello", " I am another string", " keep on learning!" ]
const names = "Kratos- Atreus- Freya- Hela- Thor- Odin";
// notice separator is a dash and a space
names.split("- ");
// output is [ "Kratos", "Atreus", "Freya", "Hela", "Thor", "Odin" ]
```
#### معلومات اكثر:

View File

@@ -17,14 +17,16 @@ localeTitle: String.prototype.substr
#### أمثلة:
`let str = "Hello world!";
let res = str.substr(1, 4);
`
```JavaScript
let str = "Hello world!";
let res = str.substr(1, 4);
```
ستكون نتيجة الدقة:
`ello
`
```
ello
```
#### معلومات اكثر:

View File

@@ -10,18 +10,20 @@ localeTitle: String.prototype.substring
أمثلة:
`"Hello, campers".substring(7, 14);
// output is "campers"
"Hello, world".substring(0, 5);
// output is "Hello"
`
```js
"Hello, campers".substring(7, 14);
// output is "campers"
"Hello, world".substring(0, 5);
// output is "Hello"
```
يمكنك أيضًا حذف معلمة فهرس الأحرف الأخيرة ، وسيتم استخراج التسلسل الفرعي من فهرس البدء حتى نهاية السلسلة. مثال:
`"Hello, campers!".substring(7);
// output is "campers!"
`
```js
"Hello, campers!".substring(7);
// output is "campers!"
```
#### معلومات اكثر:

View File

@@ -8,9 +8,10 @@ localeTitle: String.prototype.trim
أمثلة:
`" Hello, campers. I have spaces on both ends! ".trim();
// output is "Hello, campers. I have spaces on both ends!"
`
```js
" Hello, campers. I have spaces on both ends! ".trim();
// output is "Hello, campers. I have spaces on both ends!"
```
`trim()` لا يزيل فقط أحرف الفضاء. يزيل أي حرف مسافة بيضاء ، مثل علامات التبويب ، فواصل الأسطر ، فواصل عدم الانكسار ، إلخ.