Skip to content

Commit ef56045

Browse files
committed
type conversions : article.md translated
1 parent 8415785 commit ef56045

File tree

1 file changed

+58
-58
lines changed

1 file changed

+58
-58
lines changed
Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,111 @@
1-
# Type Conversions
1+
# টাইপ রূপান্তর
22

3-
Most of the time, operators and functions automatically convert the values given to them to the right type.
3+
বেশীরভাগ সময়, অপারেটর ও ফাংশন সমুহ নিজে থেকেই তাদের কাছে দেয়া ভ্যালুগুলো রূপান্তর করে থাকে।
44

5-
For example, `alert` automatically converts any value to a string to show it. Mathematical operations convert values to numbers.
5+
উদাহারণ হিসাবে , `alert` নিজে থেকেই ভ্যালুকে রূপান্তর করে স্টিংয়ে রূপান্তর করে নেয়। গানিতিক অপারেটরগুলি ভ্যালুকে সংখ্যায় রূপান্তর করে।
66

7-
There are also cases when we need to explicitly convert a value to the expected type.
7+
যদিও কিছু কিছু ক্ষেত্রে আমাদেরকেই ভ্যালুকে নিজেদের মত করে রূপান্তর করে নিতে হয়।
88

99
```smart header="Not talking about objects yet"
10-
In this chapter, we won't cover objects. Instead, we'll study primitives first. Later, after we learn about objects, we'll see how object conversion works in the chapter <info:object-toprimitive>.
10+
এই অধ্যায়ে, আমরা অবজেক্ট নয় বরং, মৌলিক বিষয়গূলো জানবো। পরবর্তিতে, অবজেক্টের ধারণা পেলে, আমরা অবজেক্ট রূপান্তর নিয়ে আলোচনা করবো। <info:object-toprimitive>.
1111
```
1212

13-
## String Conversion
13+
## স্টিং রূপান্তর
1414

15-
String conversion happens when we need the string form of a value.
15+
কোন ভ্যালু থেকে স্টিং দরকার হলে স্টিং রূপান্তর হয়।
1616

17-
For example, `alert(value)` does it to show the value.
17+
উদাহরণ স্বরূপ, `alert(value)` এইকাজটি করে ভ্যালুটিকে দেখাতে।
1818

19-
We can also call the `String(value)` function to convert a value to a string:
19+
আমরা একে `String(value)` ফাংশন থেকেও করতে পারি:
2020

2121
```js run
2222
let value = true;
23-
alert(typeof value); // boolean
23+
alert(typeof value); // বুলিয়ান
2424

2525
*!*
26-
value = String(value); // now value is a string "true"
27-
alert(typeof value); // string
26+
value = String(value); // এখন ভ্যালুটি একটি স্টিং "true"
27+
alert(typeof value); // স্টিং
2828
*/!*
2929
```
3030

31-
String conversion is mostly obvious. A `false` becomes `"false"`, `null` becomes `"null"`, etc.
31+
স্টিং রুপান্তর প্রায়শই স্পষ্ট, `false` হয়ে যায় `"false"`, `null` হয়ে যায় `"null"`, etc.
3232

33-
## Numeric Conversion
33+
## সংখ্যা রূপান্তর
3434

35-
Numeric conversion happens in mathematical functions and expressions automatically.
35+
গানিতিক ফাংশন এবং এক্সপ্রেশনের ক্ষেত্রে সংখ্যায় রুপান্তর নিজে থেকেই হয়ে থাকে।
3636

37-
For example, when division `/` is applied to non-numbers:
37+
যেমন, ভাগের `/` সময় দুটি স্টিং:
3838

3939
```js run
40-
alert( "6" / "2" ); // 3, strings are converted to numbers
40+
alert( "6" / "2" ); // 3, স্টিংয়ের সংখ্যায় বদলে যাওয়া
4141
```
4242

43-
We can use the `Number(value)` function to explicitly convert a `value` to a number:
43+
আমরা `Number(value)` ব্যাবহার করেও স্পষ্ট করে `value` কে সংখ্যায় রূপান্তর করতে পারি:
4444

4545
```js run
4646
let str = "123";
47-
alert(typeof str); // string
47+
alert(typeof str); // স্টিং
4848

49-
let num = Number(str); // becomes a number 123
49+
let num = Number(str); // সংখ্যায় 123 হয়ে গেছে
5050

51-
alert(typeof num); // number
51+
alert(typeof num); // সংখ্যা
5252
```
5353

54-
Explicit conversion is usually required when we read a value from a string-based source like a text form but expect a number to be entered.
54+
স্পট করে এই রুপান্তরের পন্থাটি তখনই কাজে লাগে যখন এমন কোন সোর্স থেকে ভ্যালু পাই যা স্টিং দেয় অথচ যার কোন সংখ্যা দেয়ার কথা, যেমন ঃ টেক্সট ফর্ম ।
5555

56-
If the string is not a valid number, the result of such a conversion is `NaN`. For instance:
56+
যদি স্টীং কোন ভ্যালিড সংখ্যা না হয় তবে তা `NaN` হয়ে যায়। যথা:
5757

5858
```js run
5959
let age = Number("an arbitrary string instead of a number");
6060

61-
alert(age); // NaN, conversion failed
61+
alert(age); // NaN, রূপান্তর হয়নি
6262
```
6363

64-
Numeric conversion rules:
64+
সংখ্যা রুপান্তরের নিয়ম:
6565

66-
| Value | Becomes... |
66+
| ভ্যালু | বদলে যায়... |
6767
|-------|-------------|
6868
|`undefined`|`NaN`|
6969
|`null`|`0`|
70-
|<code>true&nbsp;and&nbsp;false</code> | `1` and `0` |
71-
| `string` | Whitespaces from the start and end are removed. If the remaining string is empty, the result is `0`. Otherwise, the number is "read" from the string. An error gives `NaN`. |
70+
|<code>true&nbsp;&nbsp;false</code> | `1` `0` |
71+
| `string` | স্টিংয়ের শুরু ও শেষের স্পেস থেকে তা মুছে ফেলা হয়। বাকিটা খালি স্টীং হলে, তা `0` হবে। নাহয় নাম্বারগুলি স্টিং থেকে নেয়া হয়। এরর হলে `NaN` আসে। |
7272

7373
Examples:
7474

7575
```js run
7676
alert( Number(" 123 ") ); // 123
77-
alert( Number("123z") ); // NaN (error reading a number at "z")
77+
alert( Number("123z") ); // NaN ("z" এর সংখ্যা রুপান্তরে এরর)
7878
alert( Number(true) ); // 1
7979
alert( Number(false) ); // 0
8080
```
8181

82-
Please note that `null` and `undefined` behave differently here: `null` becomes zero while `undefined` becomes `NaN`.
82+
এখানে জেনে রাখি `null` `undefined` ভিন্ন আচরণ করে: `null` হয়ে যাবে শূন্য আর `undefined` হবে `NaN`.
8383

8484
````smart header="Addition '+' concatenates strings"
85-
Almost all mathematical operations convert values to numbers. A notable exception is addition `+`. If one of the added values is a string, the other one is also converted to a string.
85+
প্রায় সব গানিতিক অপারেটর ভ্যালুকে সংখ্যায় রূপান্তর করে নেয়। তবে উল্লেখযোগ্য ব্যতিক্রম হলো যোগ `+`, যদি এর দুপাশের একটি ভ্যালুও স্টিং হয় তবে অপরটিও স্টিং হয়ে যাবে
8686
87-
Then, it concatenates (joins) them:
87+
তখন এটি স্টিংগুলাকে যুক্ত করে ফেলে:
8888
8989
```js run
90-
alert( 1 + '2' ); // '12' (string to the right)
91-
alert( '1' + 2 ); // '12' (string to the left)
90+
alert( 1 + '2' ); // '12' (ডানপাশে স্টিং)
91+
alert( '1' + 2 ); // '12' (বাপাশে স্টিং)
9292
```
9393
94-
This only happens when at least one of the arguments is a string. Otherwise, values are converted to numbers.
94+
এটা তখনই হয় যদি অন্তত একটি আর্গুমেন্ট স্টিং হবে নাহয়, তা সংখ্যায় রুপান্তরিত হয়ে যাবে।
9595
````
9696

97-
## Boolean Conversion
97+
## বুলিয়ান রূপান্তর
9898

99-
Boolean conversion is the simplest one.
99+
বুলিয়ানের রূপান্তর সবচেয়ে সহজতম।
100100

101-
It happens in logical operations (later we'll meet condition tests and other similar things) but can also be performed explicitly with a call to `Boolean(value)`.
101+
এটি লজিকাল এক্সপ্রেশনের ক্ষেত্রে হয় (পরবর্তিতে কণ্ডিশনাল টেস্ট সহ অন্যগুলি দেখবো) তবে এটি সুস্পট করেও রূপান্তর করা যায় `Boolean(value)`.
102102

103-
The conversion rule:
103+
রূপান্তর নীতি:
104104

105-
- Values that are intuitively "empty", like `0`, an empty string, `null`, `undefined`, and `NaN`, become `false`.
106-
- Other values become `true`.
105+
- খালি ভ্যালু, যেমনঃ `0`, খালি স্টিং, `null`, `undefined`, `NaN`, হবে `false`.
106+
- অন্যসব হয়ে যায় `true`.
107107

108-
For instance:
108+
এক্ষেত্রে:
109109

110110
```js run
111111
alert( Boolean(1) ); // true
@@ -116,44 +116,44 @@ alert( Boolean("") ); // false
116116
```
117117

118118
````warn header="Please note: the string with zero `\"0\"` is `true`"
119-
Some languages (namely PHP) treat `"0"` as `false`. But in JavaScript, a non-empty string is always `true`.
119+
কিছু প্রোগ্রামিং ভাষায় ( পি এইচ পি ) তে `"0"` কে `false` ধরে, কিন্তু জাভাস্ক্রিপ্ট, স্টিং খালি না হলে `true` ধরে নেয়।
120120

121121
```js run
122122
alert( Boolean("0") ); // true
123-
alert( Boolean(" ") ); // spaces, also true (any non-empty string is true)
123+
alert( Boolean(" ") ); // স্পেস, এটাও true (স্টিং খালি না হলেই true)
124124
```
125125
````
126126
127-
## Summary
127+
## সারসংক্ষেপ
128128
129-
The three most widely used type conversions are to string, to number, and to boolean.
129+
বহুল ব্যাবহৃত ৩টি রূপান্তর হচ্ছে স্টিংয়ে,সংখ্যায়, বুলিয়ানে।
130130
131-
**`String Conversion`** -- Occurs when we output something. Can be performed with `String(value)`. The conversion to string is usually obvious for primitive values.
131+
**`স্টিংয়ে রূপান্তর`** -- আউটপুট দেখতে হলে হয়। অথবা `String(value)` দিয়ে করা যায়। প্রায় সব মৌলিক ভ্যালুর জন্য এটা খুব জরুরী।
132132
133-
**`Numeric Conversion`** -- Occurs in math operations. Can be performed with `Number(value)`.
133+
**`সংখ্যায় রূপান্তর`** -- গানিতিক অপারেশনে হয়। `Number(value)` দিয়েও করতে পারি।
134134
135-
The conversion follows the rules:
135+
রূপান্তর নীতি:
136136
137-
| Value | Becomes... |
137+
| ভ্যালু | বদলে যায়... |
138138
|-------|-------------|
139139
|`undefined`|`NaN`|
140140
|`null`|`0`|
141141
|<code>true&nbsp;/&nbsp;false</code> | `1 / 0` |
142-
| `string` | The string is read "as is", whitespaces from both sides are ignored. An empty string becomes `0`. An error gives `NaN`. |
142+
| `string` | স্টিংয়ে যা তাই আসে, স্টিংয়ের শুরু ও শেষের স্পেস থেকে তা মুছে ফেলা হয়। বাকিটা খালি স্টীং হলে, তা `0` হবে। নাহয় নাম্বারগুলি স্টিং থেকে নেয়া হয়। এরর হলে `NaN` আসে। |
143143
144-
**`Boolean Conversion`** -- Occurs in logical operations. Can be performed with `Boolean(value)`.
144+
**`বুলিয়ানে রূপান্তর`** -- লজিকাল অপারেশনে হয়। আবার `Boolean(value)` দিয়েও করা যায।
145145
146146
Follows the rules:
147147
148-
| Value | Becomes... |
148+
| ভ্যালু | বদলে যায়... |
149149
|-------|-------------|
150150
|`0`, `null`, `undefined`, `NaN`, `""` |`false`|
151-
|any other value| `true` |
151+
|অন্য যেকোন ভ্যালু| `true` |
152152
153153
154-
Most of these rules are easy to understand and memorize. The notable exceptions where people usually make mistakes are:
154+
প্রায় সব নীতিই বুঝা অ মনে রাখা সোজা। তবে কিছু কমন ভুল হলো:
155155
156-
- `undefined` is `NaN` as a number, not `0`.
157-
- `"0"` and space-only strings like `" "` are true as a boolean.
156+
- `undefined` হয় `NaN` সংখ্যা হিসাব করলে, `0` নয়
157+
- `"0"` ও স্পেস `" "` বুলিয়ানে true
158158
159-
Objects aren't covered here. We'll return to them later in the chapter <info:object-toprimitive> that is devoted exclusively to objects after we learn more basic things about JavaScript.
159+
অবজেক্ট এখানে কভার করা হয় নি। আমরা এখানে আবার আসবো। <info:object-toprimitive> এটা শুধুই অব্জেক্টের জন্য যখন আমরা আরো ভালো করে জাভাস্ক্রিপ্ট শিখে ফেলবো.

0 commit comments

Comments
 (0)