Operators

JavaScript operators are the symbols/keywords that perform actions on values: arithmetic, comparisons, logical flow, assignment, bitwise ops, and more.
In Bnlang, the operator tokens are identical across English, Bangla, and Banglish (e.g., +, ===, &&, ??, instanceof, in, typeof, delete, new, await, yield, void).


Quick Notes

  • + is addition and also string concatenation; unary +x coerces to number.
  • == does coercive equality; prefer === for strict equality.
  • ?? returns right side only if left is null or undefined (unlike || which treats many falsy values).
  • &&=, ||=, ??= are logical assignment operators.
  • yield (generator) and await (async) are contextual.
  • Optional chaining ?. and spread/rest ... are punctuators often called “operators.” Included here for completeness.

Operator Tables by Category

গাণিতিক (Arithmetic)

অপারেটরনামউদাহরণনোট
+যোগ / স্ট্রিং জোড়া1 + 2, "a" + "b"সংখ্যা যোগ বা স্ট্রিং concat
-বিয়োগ7 - 3
*গুণ4 * 2
/ভাগ7 / 2ফ্লোট ফল; Math.floor ব্যবহার করে নামানো যায়
%ভাগশেষ7 % 3remainder
**ঘাত2 ** 3exponentiation
+xইউনারি প্লাস+"42"number‑e coercion
-xইউনারি মাইনাস-"5"negation/coercion

ইনক্রিমেন্ট/ডিক্রিমেন্ট

অপারেটরনামউদাহরণনোট
++xপ্রিফিক্স ইনক্রিমেন্ট++iবাড়িয়ে নতুন মান ফেরত
x++পোস্টফিক্স ইনক্রিমেন্টi++পুরনো মান ফেরত, পরে বাড়ে
--xপ্রিফিক্স ডিক্রিমেন্ট--i
x--পোস্টফিক্স ডিক্রিমেন্টi--

তুলনা (Comparison)

অপারেটরনামউদাহরণনোট
=== / !==কঠোর সমতা/অসমতাa === bcoercion নেই
== / !=শিথিল সমতা/অসমতা"5" == 5coercion হয়—এড়ানো ভালো
<, <=, >, >=সম্পর্ক অপারেটরa < bস্ট্রিং তুলনায় lexicographic

লজিক্যাল ও নালিশ (Logical & Nullish)

অপারেটরনামউদাহরণনোট
&&ANDa && bshort‑circuit
``OR
!NOT!xbooleanize
??Nullish coalescingx ?? yকেবল null/undefined হলে y
&&=, `=, ??=`Logical assignment

অ্যাসাইনমেন্ট (Assignment)

অপারেটরনামউদাহরণ
=অ্যাসাইনx = 5
+=, -=, *=, /=, %=গাণিতিক অ্যাসাইনx += 2
**=ঘাত অ্যাসাইনx **= 2
<<=, >>=, >>>=শিফট অ্যাসাইনx <<= 1
&=, ^=, `=`বিটওয়াইজ অ্যাসাইন

বিটওয়াইজ (Bitwise)

অপারেটরনামউদাহরণ
&ANDa & b
``OR
^XORa ^ b
~NOT~x
<<বাম শিফটx << 2
>>ডান শিফট (sign‑prop)x >> 1
>>>জিরো‑ফিল ডান শিফটx >>> 1

রিলেশনাল/টাইপ (Relational/Type/Other)

অপারেটরনামউদাহরণনোট
typeofটাইপ নির্ণয়typeof xফল স্ট্রিং
instanceofকন্সট্রাক্টর সম্পর্কx instanceof Cপ্রোটোটাইপ‑চেইন
inপ্রপার্টি আছে?"name" in objপ্রোটোটাইপসহ
deleteপ্রপার্টি মুছুনdelete obj.x
voidundefined করুনvoid exprমান ফেলে দেয়
newকন্সট্রাক্ট ইনস্ট্যান্সnew C()
awaitপ্রমিস অপেক্ষাawait pasync‑এ
yield, yield*জেনারেটর ফলানোyield xgen‑এ

কন্ডিশনাল, কমা, অপশনাল/স্প্রেড

অপারেটরনামউদাহরণনোট
?:টার্নারিcond ? a : bএক্সপ্রেশন‑লেভেল if
,কমা(a = 1, b = 2)বাম চালিয়ে ডান ফল
?.অপশনাল চেইনobj?.prop()পাংচুয়েটর
...স্প্রেড/রেস্ট[...xs], function f(...a){}পাংচুয়েটর

উদাহরণ:

const user = { name: "Mamun" };
const label = user?.name ?? "Guest";
let x = 2; x **= 3;           // 8
const list = [1, 2]; const more = [...list, 3]; // [1,2,3]
if (a > 0 && b > 0) print("both positive");

Precedence (Common Highlights)

  • Highest → lowest (selected): () call/member → new** → unary (! ~ + - typeof void delete await) → * / %+ - → shifts (<< >> >>>) → comparisons (< <= > >= in instanceof) → equality (== != === !==) → logical AND && → logical OR || → nullish ?? → conditional ?: → assignment (=, +=, … &&= ||= ??=) → comma ,.
  • ** is right‑associative; most arithmetic is left‑associative. Ternary ?: is right‑associative.
  • Mixing ?? with ||/&& needs parentheses.

Notes

  • BigInt works with most arithmetic/bitwise ops but cannot mix with Number (e.g., 1n + 1 → TypeError).
  • typeof null === "object" (historical quirk). Arrays/dates/regex show "object".
  • in checks across the prototype chain; for own‑props use Object.hasOwn(obj, key).
  • Spread ... and optional chaining ?. are punctuators commonly treated as operators.