Created by w3resource.com / @w3resource
InstructionsJavaScript recognizes the following types of primitive values.
A JavaScript variable must start with a letter (A-Z, a-z), underscore (_), or dollar sign ($), subsequent characters can also be digits (0-9).
- Declaring variables -
Use literals to represent values in JavaScript which are fixed values, not variables.
The Boolean type has two literal values :
Integers can be expressed in decimal (base 10), hexadecimal (base 16), and octal (base 8). An integer must have at least one digit (0-9).
A floating number has the following parts.
The exponent part is an "e" or "E" followed by an integer, which can be signed (preceded by "+" or "-").
ExpressionsAn expression is any valid unit of code that resolves to a value. Conceptually, there are two types of expressions: those that assign a value to a variable (a = 12) and those that simply have a value (5-3).
Expression categories
JavaScript has the following types of operators.
addition (+), subtraction (-), multiplication (*), and division (/). In addition, JavaScript provides the following arithmetic operators.
% (Modulus) Returns the integer remainder of dividing the two operands. 16 % 5 returns 1. ++ (Increment) Unary operator. Adds one to its operand. If x is 3, then ++x returns 4, whereas x++ returns 3. -- (Decrement) Unary operator. If x is 3, then --x returns 2, whereas x-- returns 3. - (Unary negation) Unary operator. Returns the negation of its operand. If x is 3, then -x returns -3. Assignment operators (1/2) Shorthand Expression Description a +=b a = a + b Adds 2 numbers and assigns the result to the first. a -= b a = a - b Subtracts 2 numbers and assigns the result to the first. a *= b a = a*b Multiplies 2 numbers and assigns the result to the first. a /=b a = a/b Divides 2 numbers and assigns the result to the first. a %= b a = a%b Computes the modulus of 2 numbers and assigns the result to the first. Assignment operators (2/2) a<<=b a = a<<b Performs a left shift and assigns the result to the first operand. a>>=b a = a>>b Performs a sign-propagating right shift and assigns the result to the first operand. a>>>=b a = a>>>b Performs a zero-fill right shift and assigns the result to the first operand. a&= b a = a&b Performs a bitwise AND and assigns the result to the first operand. a^= b a = a^b Performs a bitwise XOR and assigns the result to the first operand. a |=b a = a|b Performs a bitwise OR and assigns the result to the first operand. Comparison Operators(1/2) Operator ComparisonsWhen working with JavaScript strings sometimes you need to join two or more strings together in to a single string. Joining multiple strings together is known as concatenation.
The concatenation operator (+) concatenates two or more string values together and return another string which is the union of the two operand strings.
Special OperatorsJavaScript has the following special operators.
The new operator is used to create an instance of a user-defined object type or of one of the predefined object types Array, Boolean, Date, Function, Image, Number, Object, Option, RegExp, or String.
Syntax : var objectName = new objectType([param1, param2, ..., paramN]);
this OperatorThe this operator is used to refer the current object. In general, this refers to the calling object in a method.
Syntax : this["propertyName"] Label statementLabel statement provides an identifier for a statement that lets you refer to it using a break or continue statement.
JS Bin JavaScript ObjectsIn JavaScript all values except the primitive types of JavaScript (true, false, numbers, strings, null and undefined) are objects.
Here objects contain -> propertyName: propertyValue pairs.
Predefined Core ObjectsJavaScript has the following predefined objects.
Thank you for your time and attention, Go to Home page
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4