Important Notice:

Special Operators

Special Operators

43 views 1 min read

8. स्पेशल ऑपरेटर (Special Operators)

JS के कुछ विशेष ऑपरेटर:

typeof
काम: डेटा टाइप बताता है
उदाहरण: typeof 42 → "number"

console.log(typeof "Hello"); // string

instanceof
काम: चेक करता है कि ऑब्जेक्ट किसी विशेष क्लास का instance है या नहीं
उदाहरण:

let fruits = ["Apple", "Mango", "Banana"];

// instanceof check
console.log(fruits instanceof Array); // true
console.log(fruits instanceof Object); // true
console.log(fruits instanceof String); // false

delete
काम: ऑब्जेक्ट से कोई प्रॉपर्टी हटाता है
उदाहरण: delete obj.name

let obj = {a: 1, b: 2};
delete obj.a;
console.log(obj);

8. Special Operators
Some special operators in JavaScript:

typeof
What it does: Tells the data type
Example: typeof 42 → "number"
console.log(typeof "Hello"); // string

instanceof
What it does: Checks whether an object is an instance of a particular class
Example: [] instanceof Array → true
console.log([] instanceof Array); // true

delete
What it does: Removes a property from an object
Example: delete obj.name

text

let obj = {a: 1, b: 2}; delete obj.a; console.log(obj); // {b: 2}

void
What it does: Evaluates an expression but returns undefined
Example: void(0) → undefined

, (comma operator)
What it does: Runs multiple expressions one by one and returns the value of the last expression
Example: let x = (5, 10, 15); → x becomes 15

Related Notes