CoderFunda
  • Home
  • About us
    • Contact Us
    • Disclaimer
    • Privacy Policy
    • About us
  • Home
  • Php
  • HTML
  • CSS
  • JavaScript
    • JavaScript
    • Jquery
    • JqueryUI
    • Stock
  • SQL
  • Vue.Js
  • Python
  • Wordpress
  • C++
    • C++
    • C
  • Laravel
    • Laravel
      • Overview
      • Namespaces
      • Middleware
      • Routing
      • Configuration
      • Application Structure
      • Installation
    • Overview
  • DBMS
    • DBMS
      • PL/SQL
      • SQLite
      • MongoDB
      • Cassandra
      • MySQL
      • Oracle
      • CouchDB
      • Neo4j
      • DB2
      • Quiz
    • Overview
  • Entertainment
    • TV Series Update
    • Movie Review
    • Movie Review
  • More
    • Vue. Js
    • Php Question
    • Php Interview Question
    • Laravel Interview Question
    • SQL Interview Question
    • IAS Interview Question
    • PCS Interview Question
    • Technology
    • Other

04 January, 2019

JavaScript Operators

 Programing Coderfunda     January 04, 2019     JavaScript, JavaScript Operators     No comments   

JavaScript Operators 

Variables में values सिर्फ उन्हें बाद में display करवाने के लिए ही नहीं बल्कि इसलिए भी store की जाती है  ताकि उनके साथ अलग अलग तरह के operations perform किये जा सके। Variables की values के साथ operations perform करने के लिए आपको operators की जरुरत होती है।

जैसे की आप 2 variables की values को add करना चाहते है। इसके लिए आप addition (+) operator यूज़ करेंगे। और यदि आप 2 variables की values को compare करना चाहते है तो आप relational operators यूज़ करते है। आइये operators के बारे में और जानने से पहले कुछ important terms के बारे में जान लेते है। 

What is Operand? 

Operators जिन variables पर apply होते है या जिन variables के साथ यूज़ किये जाते है, उन variables को operands कहा जाता है। जैसे नीचे लिखे हुए statement को देखिये। 
  c = a+b;
इस statement में a और b operands है। C भी एक operand है क्योंकि (=) operator इस पर apply हो रहा है।

Types of Operators 

Operators unary और binary दो तरह के होते है। Unary operators वो operators होते है जो सिर्फ एक variable पर ही apply होते है। जैसे की (~) NOT operator है। ये operator सिर्फ एक ही variable के साथ apply किया जाता है। 
Binary operators वो operators होते है जिनके execution के लिए 2 operators required होते है। जैसे की (+) operator है। इस operator को आप किसी single variable के साथ यूज़ नहीं कर सकते है। इस variable को execute होने के लिए 2 operands की आवश्यकता होती है। 

JavaScript Arithmetic Operators 

Arithmetic operations perform करने के लिए arithmetic operators यूज़ किये जाते है। इनके बारे में नीचे दिया जा रहा है।
Operator
Explanation
Example
Negation(-) unary
Opposite values of a variable 
-a
Addition (+)
It adds values of 2 or more variables 
a+b
Subtraction(-)
Subtract value of one variable from other variables value
a-b
Multiplication(*)
Multiply values of 2 variables
a*b
Division(/)
Divide value of one variable by value of another variable. 
a/b
Modulus
Get the remainder after division 
a%b
Exponentiation
Value of first variable raise to power to value of second variable 
a**b
   

JavaScript Relational Operators 

Relational operators के द्वारा आप 2 variables की values को compare कर सकते है। ये operators ज्यादातर control statements में यूज़ होते है जब आप logic build करने की कोशिश करते है। जैसे की कौनसा variable बड़ा या छोटा है। 

Operator
Explanation
Example
Equal (==)
ये operator 2  variables की values को equality के लिए compare करता है।  
a==b;
Not Equal (!=)
ये operator 2 variables की values को non equality के लिए check करता है।  
a!=b;
Less than (<)
ये operator ये check करता है की left side का variable right side के variable से छोटा है या नहीं।  
a<b;
Greater than (>)
ये operator check करता है की right side वाला variable left side वाले variable से बड़ा है या नहीं।  
a>b;
Less than equal to (<=)
ये operator check करता है की left side का variable right के variable के बराबर है या उससे छोटा है या नहीं।  
a<=b;
Greater than equal to (>=)
ये operator check करता है की right side का variable left side के variable के बराबर या उससे बड़ा है या नहीं।  
a>=b;

JavaScript Bitwise Operators 

सभी variables की values bits में convert होती है। Bit wise operator के द्वारा आप bits पर operations perform कर सकते है। ये operators भी control statements में यूज़ किये जाते है। इनके बारे में नीचे दिया जा रहा है।
Operator
Explanation
Example
AND (&)
दोनों variables की values में जो common bits होती है वो return कर दी जाती है।  
a&b
OR (|)
दोनों variables की सभी bits return कर दी जाती है।  
a|b
X-OR(^)
जो bits right side के variable में नहीं है लेकिन left side के variable में है return की जाती है।  
a^b
NOT(~)
सभी bits invert करके return की जाती है।  
~a
Shift Left(<<)
सभी bits को right side के variable की value जितना left में shift किया जाता है।  
a<<b
Shift Right(>>)
सभी bits को right side के variable की value जितना right में shift किया जाता हैं।  
>>b

JavaScript Logical Operators 

Logical operators के द्वारा logic perform किया जाता है। इन operators को control statements में यूज़ किया जाता है।   

Operator
Explanation
Example
And(&&)
यदि दोनों variables की value true है तो ये operator true result return करता है।  
a&&b
Or(||)
दोनों में से कोई एक variable true हो तो भी result true ही होता है।    
a||b
Not(!)
यदि variable true है तो false होगा और यदि false है तो true हो जायेगा।  
!a
Xor
यदि दोनों से कोई एक true है तो result true होगा। और यदि दोनों false या दोनों true है तो result false होगा।   
a Xor b

JavaScript Assignment Operators 

Assignment operators variables की values आपस में assign करने के लिए यूज़ किये जाते है। JavaScript में यूज़ होने वाले assignment operators नीचे दिए जा रहे है। 
Operator
Explanation
Example
Simple assignment (=)
ये operator right variable की value left variable को assign करता है।   
a=b;
Plus assignment (+=)
ये operator left और right variables की value को add करके left variable में store करता है।   
a+=b;
Minus assignment(-=)
ये operator left side के variable की value में से right side के variable की value घटाकर result left side के variable में store करता है।   
a-=b
Multiply assignment(*=)
ये operator left और right side के variables की values को multiply करके result left side के variable में store करता है।   
a*=b
Divide assignment(/=)
ये operator left side के variable की value को right side के variable से divide करके result left side के variable में store करता है।   
a/=b

JavaScript Special Operators 

JavaScript आपको कुछ special operators provide करती है जो कुछ special operations perform करने के लिए यूज़ किये जाते है। इनमें से हर operator एक अलग purpose को fulfill करता है। इनके बारे में नीचे दिया जा रहा है।

Conditional Operator (?:) 

Conditional operator if-else की तरह ही होता है। इसे आप one-line  if else statement भी कह सकते है। इसे यूज़ करना बहुत ही आसान है। Question mark से पहले एक condition दी जाती है। यदि ये condition true होती है तो colon के पहले वाला statement और यदि false होती है तो colon के बाद वाला statement result के रूप में return किया जाता है। इसका उदाहरण नीचे दिया जा रहा है।        
z  =  (5>3) ? 5 : 3;
document.write(z); // It will print 5

Typeof Operator 

ये operator debugging के लिए बहुत helpful है। इस operator से किसी भी variable के data type का पता लगाया जा सकता है। इस operator को यूज़ करना बहुत ही आसान है। आप typeof लिख कर उसके आगे वो value या variable लिखते है जिसका data type आपको पता लगाना है। इसका उदाहरण आगे दिया गया है।

str = "hello world";
document.write(typeof  str); 
     

Void Operator 

ये operator जब भी आप JavaScript में कोई function call करते है तो उसकी return value को discard करने के लिए यूज़ किया जाता है। इसे यूज़ करना बिलकुल आसान है। जिस भी function की return value आप discard करना चाहते है उसमे आप इस operator (...) को argument की तरह pass करते है।

इसका उदाहरण नीचे दिया जा रहा है।   
 <a href="your-url" onClick="myFunction(...)">Click here</a>
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Email ThisBlogThis!Share to XShare to Facebook
Newer Post Older Post Home

0 comments:

Post a Comment

Thanks

Meta

Popular Posts

  • Writing and debugging Eloquent queries with Tinkerwell
    In this article, let's look into the options that you can use with Tinkerwell to write and debug Eloquent queries easier. The post Wr...
  • The token request was rejected by the remote server
    error:invalid_granterror_description:The token request was rejected by the remote server.error_uri: https://documentation.openiddict.com/err...
  • Vue.js Tutorial
      Vue.js Installation Compatibility Check Before going to install and use Vue.js in your project, you should check the compatibility issues....
  • JqueryUI Tutorial
    JqueryUI Tutorial    JqueryUI is the most popular front end frameworks currently. It is sleek, intuitive, and powerful mobile first fr...
  • Laravel - Application Structure
    The application structure in Laravel is basically the structure of folders, sub-folders and files included in a project. Once we create a ...

Categories

  • Ajax (26)
  • Bootstrap (30)
  • DBMS (42)
  • HTML (12)
  • HTML5 (45)
  • JavaScript (10)
  • Jquery (34)
  • Jquery UI (2)
  • JqueryUI (32)
  • Laravel (1017)
  • Laravel Tutorials (23)
  • Laravel-Question (6)
  • Magento (9)
  • Magento 2 (95)
  • MariaDB (1)
  • MySql Tutorial (2)
  • PHP-Interview-Questions (3)
  • Php Question (13)
  • Python (36)
  • RDBMS (13)
  • SQL Tutorial (79)
  • Vue.js Tutorial (69)
  • Wordpress (150)
  • Wordpress Theme (3)
  • codeigniter (108)
  • oops (4)
  • php (853)

Social Media Links

  • Follow on Twitter
  • Like on Facebook
  • Subscribe on Youtube
  • Follow on Instagram

Pages

  • Home
  • Contact Us
  • Privacy Policy
  • About us

Blog Archive

  • July (4)
  • September (100)
  • August (50)
  • July (56)
  • June (46)
  • May (59)
  • April (50)
  • March (60)
  • February (42)
  • January (53)
  • December (58)
  • November (61)
  • October (39)
  • September (36)
  • August (36)
  • July (34)
  • June (34)
  • May (36)
  • April (29)
  • March (82)
  • February (1)
  • January (8)
  • December (14)
  • November (41)
  • October (13)
  • September (5)
  • August (48)
  • July (9)
  • June (6)
  • May (119)
  • April (259)
  • March (122)
  • February (368)
  • January (33)
  • October (2)
  • July (11)
  • June (29)
  • May (25)
  • April (168)
  • March (93)
  • February (60)
  • January (28)
  • December (195)
  • November (24)
  • October (40)
  • September (55)
  • August (6)
  • July (48)
  • May (2)
  • January (2)
  • July (6)
  • June (6)
  • February (17)
  • January (69)
  • December (122)
  • November (56)
  • October (92)
  • September (76)
  • August (6)

Loading...

Laravel News

Loading...

Copyright © CoderFunda | Powered by Blogger
Design by Coderfunda | Blogger Theme by Coderfunda | Distributed By Coderfunda