Learn JavaScript In Arabic 2021 - #020 - Type Coercion

preview_player
Показать описание
Type Coercion

Study Plan:

Code & Notice:

Assignments:

=============================

Support Me on Patreon to Help me Create More Videos

I will be Very Happy if you Support my Channel.

Join Our Facebook Group:

Follow My Facebook Profile:

Like Facebook Page:

Follow Me On Twitter:
Рекомендации по теме
Комментарии
Автор

احلي تحية من طلبه حاسبات ومعلومات حلوان ❤❤❤❤

mohsenhesham
Автор

من قال سبحان الله وبحمده 100 مرة غفرت ذنوبه حتى لو كانت مثل زبد البحر ❤💖

aQraWartQe
Автор

يعني المفروض تعطينا مثال لهم في html & css حتى نفهم فائدتهم حتى نسوي تجارب لهم

P_Ahmed_P
Автор

محتاجين كورس react js بعد الكورس هذا الكورس الجميل مشكور ع مجهودك استاذ

edrisqudaam
Автор

بصراحة قلبت معي الامور من عمليات جافا سكريبت, و عمليات الجافا و البايثون

ahamdgdaisat
Автор

أستاد اسامه بما انو قناتك ملمه بكل اشياء الباك ايند وفرونت ايند ف شو رأيك تنزل فديو كيف ترفع موقع على الانترنيت حتى تكمل السلسه و نطرق لهاي الاوامر وشكراً مقدمةً

pqpdbvy
Автор

والله اشتقت جدا لفيديوهات حضرتك انا موقف الفتره دي علشان ثانوية عامه ادعولي جزاكم الله خيرا

theplayer
Автор

افضل شئ انك تسوي المقاطع قصيره دا اللي بيساعد عل التعلم وما يوجد الملل

abdulrhmankhalifa
Автор

بارك الله فيك أخ أسامة على مجهودك المبارك أدام الله عليك الصحة والعافية

gufbqub
Автор

بارك الله فيك على مجهوداتك، جعلها الله لك حسنة جارية.

abedbenya
Автор

من سوريا اشكرك يا استاذ والله احسن من شرح برمجة بالعالم ❤❤❤

Hussein....
Автор

عظمة كالعادة يا بشمهندس
ربنا يوفقك ويجزاك خير علي الي بتقدمه للناس من علم بكل حب
هفضل احطلك الكومنت دا علي كل فيديو اذاكره في الكورس دا

FartakaTechnology
Автор

In summary, type coercion happens implicitly during operations, while type casting involves explicitly converting a value from one type to another using functions or methods.

يعنى باختصار ال type coercion بيحصل اثناء لما الكود بيرن انت مش بتتدخل
اما ال type casting انت اللى بتقول حول ده ل ده زى مثلا لما تحول رقم جوه استرينج ل رقم ب ال unary operator

abdomahmoud
Автор

صلوا على الحبيب المصطفى صلى الله عليه وسلم

rodwangd
Автор

ممتاز الدرس لانه كنت متلخبط من هذي 10+ "20" يعني مفترض يكون ارقام و احرف ليس ارقام فقط ولكن ألان فهمت. شكرآ لك أستاذ اسامة

mraziz
Автор

استاذي العظيم اشكرك بشدة جدا جدا انا بستفاد كتيييير اوي من حضرتك انا اسمي نبيل نصر طالب ف 2 ثانوي عسكري عندي 15 سنة من القاهرة من مصر بدرس برمجة من 7/12/2015 وتخصصي سيكيورتي بس درست نوعا ما الويب تحت ايد حضرتك والهندسة العكسية درست ال Lunix + و Python وال Bash Scripting. وبدرس الHtml. وال Css والjava script تحت ايد حضرتك 🌹 وال Ruby وال C++ ولسا مكمل فدراسة البرمجة حتي الان بس ودارس الشبكات بس مش بشكل عميق اوي الحمدلله وبدرس دلواقتي ال Security + وال Network.+ وال MSCA وال CCNA وال CEHوهدفي باذن الله اني اوصل لل CISSP شكرا ليك بجد يا استاذي ربنا يديم كل اللي حضرتك بتعمله دا ويخليه فميزان حسناتك يارب 🤲🏻 شكرا ليك علي كل معلومة اديتهتلنا يارب ربنا يديمك لينا يهندسة ويديم وجودك معانا ونتعلم منك دايما ودايما يارب 🤲🏻🤝🌹

jokerphotoshop
Автор

about type coersion : In JavaScript, the `+` operator can serve multiple purposes depending
on the context in which it's used. One of its main purposes is addition,
but it can also be used for string concatenation and type coercion.

1. **Addition (Arithmetic Operation)**:
When the `+` operator is used with numbers, it performs addition,
adding the values together.

```javascript
var num1 = 5;
var num2 = 2;
var sum = num1 + num2; // sum is 7 (the result of addition)
```

2. **String Concatenation**:
When the `+` operator is used with at least one string,
it concatenates the values into a new string.

```javascript
var str1 = "Hello, ";
var str2 = "world!";
var greeting = str1 + str2; // greeting is "Hello, world!"
```

3. **Type Coercion to String**:
If one of the operands is a string, and the other is not a string,
the non-string value is implicitly coerced into a string and concatenated.

```javascript
var num = 42;
var str = "The number is: " + num; // num is implicitly coerced to a
string for concatenation
```

4. **Type Coercion to Number**:
If both operands are numbers or can be interpreted as numbers, the `+` operator
performs addition.

```javascript
var strNum = "42";
var num = 10;
var result = num + Number(strNum); // Explicitly coerce strNum to a number
for addition
```

In the context where the `+` operator is used for addition or arithmetic operations
and one of the operands is not a number, JavaScript will attempt to convert the
non-numeric operand into a number (if possible) for the operation. This is a form
of implicit type coercion.

Understanding how the `+` operator behaves depending on the context is crucial for
writing JavaScript code that behaves as expected and avoids unexpected outcomes.
//BOOLEEN
In JavaScript, the `+` operator behaves differently based on the data types of
the operands involved. When it comes to boolean values and the `+` operator,
here's how it works:

1. **Boolean Coercion**:
- When a boolean value is used with the `+` operator, JavaScript will implicitly
coerce it into a number. `true` is coerced to `1`, and `false` is coerced to `0`.

```javascript
var trueValue = true;
var falseValue = false;

var trueAsNumber = +trueValue; // trueValue is coerced to 1
var falseAsNumber = +falseValue; // falseValue is coerced to 0

console.log(trueAsNumber); // Outputs: 1
console.log(falseAsNumber); // Outputs: 0
```

2. **String Concatenation with Booleans**:
- When a boolean value is used with the `+` operator in a string concatenation
context, it is implicitly coerced to a string.

```javascript
var isTrue = true;
var isFalse = false;

var result1 = "The value is: " + isTrue; // isTrue is coerced to "true"
var result2 = "The value is: " + isFalse; // isFalse is coerced to "false"

console.log(result1); // Outputs: "The value is: true"
console.log(result2); // Outputs: "The value is: false"
```

In summary, when using the `+` operator with booleans:
- In arithmetic or numeric context, `true` is coerced to `1` and `false`
is coerced to `0`.
- In string concatenation context, booleans are implicitly coerced
to strings for concatenation.

Understanding how JavaScript handles boolean coercion with the `+` operator
is important to ensure that the desired behavior is achieved in your code.

besma
Автор

الجافا سكريبت اتابعها من اول فيديو لها ام اكتفى باخر ما تقدمه ؟ جزاك الله خيرا يا ريت توضح لى

lateefamer