MVC

  • Home
  • HTML
    • Overview
    • Formatting
  • Java Script
    • Overview
    • Validation
  • CSS
    • Overview
  • Sql
    • Overview
    • SQL Select
    • SQL Command
    • Advance Query
    • SQL Create
    • Function
    • Function vs StoreProcedure
    • Stored Procedures
  • MVC
    • OverView
    • Evolution of MVC
    • Install VisualStudio-2015
    • Create First Application
  • LINQ
    • Introduction
  • Privacy Policy

Sunday, 30 April 2017

Operator in JavaScript

  Unknown       04:25       javascriptOverview       No comments    

What is an operator?


JavaScript has both binary and unary operators, and one special ternary operator, the conditional operator. A binary operator requires two operands, one before the operator and one after the operator:
operand1 operator operand2
For example, 3+4 or x*y.

A unary operator requires a single operand, either before or after the operator:
operator operand
or
operand operator
For example, x++ or ++x.
Let us take a simple expression 5 + 5 is equal to 10. Here 5 and 5 are called operands and ‘+’ is called the operator.
JavaScript supports the following types of operators.

  • Arithmetic Operators
  • Comparision Operators
  • Logical (or Relational) Operators
  • Assignment Operators
  • String Operators
  • Conditional (or ternary) Operators


Using this operator we easly add,subtract,multiply,divide etc like see in example. Operator Description Example Result.

Arithmetic Operators

Operator Description Example Expression Result
+ Addition x=2
y=2
x+y 4
- Subtraction x=5, y=3 x-y 2
* Multiplication x=5,y=5 x*y 25
/ Division x=15,y=5 x/y 3
% Modulus (division remainder) x=5,y=2 x%y 1
++ Increment x=5 x++ 6
-- Decrement x=5 x-- 4

Comparison Operators

Operator Description Example
== is equal to5==8 returns false
=== is equal to (checks for both value and type) x=5,y="5"
x==y returns true
x===y returns false
!= is not equal 5!=8 returns true
> is greater than 5>8 returns false
>= is Greter than equal 5 >=8 returns false
< is Less than 5 <8 returns true
<= is Less than equal 5 <=8 returns true

Logical Operators

Operator Description Example
&& and x=6
y=3
(x < 10 && y > 1) returns true
|| or x=6
y=3
x==5 || y==5) returns false
! Not x=5
y=2
!(x==y) returns true

Assignment Operators

In this opertor You can assign value in variable in javascript
Syntex -    var x= value;
Example - var x = 5;
=  this is Assign Operator you can assign any value using this operator. In this example assign 5 value in x variable and use this

String Operators

A string is most often text, for example "Hello World!". To stick two or more string variables together, use the + operator.
txt1="How a very";
txt2="nice flower
txt3=txt1+txt2;

The variable txt3 now contains "How a verynice flower!". To add a space between two string variables, insert a space into the expression, OR in one of the strings.
txt1="How a very";
txt2="nice flower!";
txt3=txt1+" "+txt2;
or
txt1="How a very ";
txt2="nice flower!";
txt3=txt1+txt2;

The variable txt3 now contains "How a very nice flower!".

Conditional Operators


JavaScript also contains a conditional operator that assigns a value to a variable based on some condition.
Syntax
variablename=(condition)?value1:value2
Example
greeting=(visitor=="PRES")?"Dear President ":"Dear ";
If the variable visitor is equal to PRES, then put the string "Dear President " in the variable
named greeting. If the variable visitor is not equal to PRES, then put the string "Dear " into the variable named greeting.
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
Email This BlogThis! Share to X Share to Facebook
Newer Post Older Post Home

0 comments :

Post a Comment

learningmvctutorial

Popular Posts

  • Overview
      SQL (Structured Query Language)   SQL  is a language that interacts with the database on the server-side. This dynamite duo has changed ...
  • Overview of HTML
    What is HTML? First developed by Tim Berners-Lee in 1990 . HTML is used to create electronic documents (called pages) that are displ...
  • Difference Between function v/s store procedure
    Definition  of Store Procedure In a database management system (DBMS), a  stored procedure  is a set of Structured Query Language (SQL...
  • SQL Select
    The SQL SELECT Statement The SELECT statement is used to select data from a database. SQL SELECT Syntax SELECT column_name , column_n...
  • What is LINQ
    LINQ  (Language Integrated Query) is a Microsoft programming model and methodology that essentially adds formal query capabilities into Mic...
  • What is Function in Sql Server
    A function is a block of code that has a name and it has a property that it is reusable. We use function in store Procedure and queries in...
  • Create Duplicate Table of existing table in SQL Server
    In This Tutorial we create table and want to same structure and same data then We create new table with data type after that  insert in ta...
  • About Javascript
    What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting langua...
  • Operator in JavaScript
    What is an operator? JavaScript has both binary and unary operators, and one special ternary operator, the conditional operator. A binar...
  • Open Application in MVC
    We want to create application in MVC first of how we create first application Show Steps   as below-     STEP 1 .  Start Computer and  I...

Blog Archive

  • ▼  2017 ( 35 )
    • ►  November ( 1 )
    • ►  October ( 2 )
    • ►  September ( 4 )
    • ►  August ( 1 )
    • ►  July ( 1 )
    • ►  May ( 3 )
    • ▼  April ( 7 )
      • Fetch Unique random Record in sql server
      • Operator in JavaScript
      • Conditional Statements in JavaScript
      • Create Duplicate Table of existing table in SQL Se...
      • Email Validation using Regex Expression in Javascript
      • About Javascript
      • Advantage and Disadvantage of LINQ
    • ►  March ( 13 )
    • ►  February ( 3 )
Powered by Blogger.

Categories

  • AdvanceQuery
  • CreateApplication
  • CreateDb
  • CssOverview
  • Evolution
  • Formatting
  • Function
  • FunctionVSSp
  • HtmlOverview
  • InstallVisualStudio
  • Introduction
  • javascriptOverview
  • JsValidation
  • Mvc-vs-Asp.Net
  • OverView
  • Select
  • SqlCommand
  • SQLOverview
  • StoredProcedures

Text Widget

Sample Text

Pages

  • Home

Copyright © MVC | Powered by Blogger
Design by Vibha Acharya