Arrow functions revisited by msisaifu · Pull Request #168 · javascript-tutorial/bn.javascript.info

@msisaifu

@msisaifu

jaamaalxyz

- ...এছাড়া আরো অনেক ক্ষেত্রে।

It's in the very spirit of JavaScript to create a function and pass it somewhere.
অনেক সময় আমাদের কোন ফাংশন লিখ তা অন্য কোন কন্টেক্সে ব্যবহার করতে হয়।

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change: অনেক সময় আমাদের কোন ফাংশন লিখ তা অন্য কোন কন্টেক্সে ব্যবহার করতে হয়।
to অনেক সময় আমাদের কোন একটি ফাংশন লিখে তা অন্য আরেকটি ফাংশনের কন্টেক্সে ব্যবহার করতে হয়।

jaamaalxyz

অনেক সময় আমাদের কোন ফাংশন লিখ তা অন্য কোন কন্টেক্সে ব্যবহার করতে হয়।

And in such functions we usually don't want to leave the current context. That's where arrow functions come in handy.
এবং এসব ক্ষেত্রে আমরা ফাংশনটিকে কারেন্ট কন্টেক্স কল করতে চাই। এক্ষেত্রে অ্যারো ফাংশন আমাদের অনেক সুবিধা দেয়।

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change: এবং এসব ক্ষেত্রে আমরা ফাংশনটিকে কারেন্ট কন্টেক্স কল করতে চাই। এক্ষেত্রে অ্যারো ফাংশন আমাদের অনেক সুবিধা দেয়।
To : এবং এসব ক্ষেত্রে আমরা ফাংশনটিকে কারেন্ট কন্টেক্সে কল করতে চাই। এক্ষেত্রে অ্যারো ফাংশন আমাদের অনেক সুবিধা দেয়।

jaamaalxyz


```warn header="Arrow functions can't run with `new`"
Not having `this` naturally means another limitation: arrow functions can't be used as constructors. They can't be called with `new`.
```warn header="`new` এ সাথে অ্যারো ফাংশন রান করে না"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change: new এ সাথে অ্যারো ফাংশন রান করে না"
To : new এর সাথে অ্যারো ফাংশন রান করে না"

jaamaalxyz


```smart header="Arrow functions VS bind"
There's a subtle difference between an arrow function `=>` and a regular function called with `.bind(this)`:
অ্যারো ফাংশন `=>` এবং ্রেগুলার ফাংশন `.bind(this)` এর মাঝে একটি পার্থক্য আছে:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change: অ্যারো ফাংশন => এবং ্রেগুলার ফাংশন .bind(this) এর মাঝে একটি পার্থক্য আছে
To: অ্যারো ফাংশন => এবং রেগুলার ফাংশন .bind(this) এর মাঝে একটি পার্থক্য আছে

jaamaalxyz

That's great for decorators, when we need to forward a call with the current `this` and `arguments`.

For instance, `defer(f, ms)` gets a function and returns a wrapper around it that delays the call by `ms` milliseconds:
ডেকোরেটার্সের জন্য এটি দারুণ, যখন আমাদের `this` এবং `arguments` এর সাহায্যে একটি ফরওয়ার্ড কল করতে হয়।

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please dont mention decorators as ডেকোরেটার্স rather use ডেকোরেটর ফাংশন or in plurals ডেকোরেটর ফাংশন গুলোর

jaamaalxyz

```

The same without an arrow function would look like:
অ্যারো ফাংশন ছাড়া ডেকোরেটার্সটি দেখতে এমন হত:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update this line following the last comment regarding decorators

jaamaalxyz

```

Here we had to create additional variables `args` and `ctx` so that the function inside `setTimeout` could take them.
এখানে আমাদের `setTimeout` ফাংশনের কন্টেক্সট এর জন্য আলাদা দুটি `args` এবং `ctx` ভ্যারিয়েবল লাগছে।

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change to: এখানে আমাদের অতিরিক্ত ভেরিয়েবল args এবং ctx তৈরি করতে হয়েছিল যাতে setTimeout-এর ভিতরের ফাংশন সেগুলোকে ব্যবহার পারে।

jaamaalxyz

- এছাড়াও এর `super` নাই, এ ব্যাপারে আমরা এখনো পড়িনি। এই অধ্যায়ে বিস্তারিত জানতে পারব <info:class-inheritance>

That's because they are meant for short pieces of code that do not have their own "context", but rather work in the current one. And they really shine in that use case.
এটি দ্বারা বোঝায় অ্যারো ফাংশনের নিজস্ব কোন "context" নাই, তবে "current context" এর সাথে কাজ করে। এধরণের ক্ষেত্রে এরা আসলেই সুবিধাজনক।

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change to: অ্যারো ফাংশন মূলত কোডের ছোট ছোট টুকরো। যা নির্দিষ্ট একটি কাজ করতে পারে। যেগুলির নিজস্ব context নেই, বরং current context এ কাজ করে।

jaamaalxyz

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the guidelines and resolve all the change requests. appreciate your hard work.

@javascript-translate-bot

Please make the requested changes. After it, add a comment "/done".
Then I'll ask for a new review 👻