Home > Web Front-end > JS Tutorial > What JavaScript Symbols and Operators Do You Need to Know?

What JavaScript Symbols and Operators Do You Need to Know?

Mary-Kate Olsen
Release: 2024-12-28 01:51:14
Original
738 people have browsed it

What JavaScript Symbols and Operators Do You Need to Know?

What does this symbol mean in JavaScript?

Symbol Description Type

this The current object References an object

var x = function() vs. function x() Function declaration syntax Declares a function

(function(){…})() Immediately Invoked Function Expression (IIFE) Immediately executes a function

someFunction()() Functions that return other functions Returns a function

=> Arrow function expression syntax Defines an arrow function

|> Pipe, greater than Pipeline operator Pipes output of one function to input of another

function, yield, yield Generator functions Defines a generator function

[…], [ value ], Array() Array notation Declares an array

{…}, { key: value }, { [key]: value } Object literal syntax Defines an object

…${…}… Template literals Inserts variables into strings

/…/ Regular expression literals Matches text patterns

$ Dollar sign in regex replace patterns Matches specific parts of a string in regex replace

() Grouping operator Groups expressions for evaluation

obj.prop, obj[prop], obj["prop"] Property accessors Access properties of objects

?. , ?.[], ?.() Optional chaining operator Safe navigation of property access

new operator Creates a new object

...iter Spread syntax Spreads array or object into individual elements

, -- Pre- / post-increment / -decrement operators Increment or decrement a value

, - Addition or concatenation, and subtraction operators; unary sign operators Perform arithmetic or logical operations

&&, ||, ! Logical operators Perform logical operations

?., ?.[], ?.() Optional chaining operator Safe navigation of property access

** Power operator (exponentiation) Raises a value to a power

==, === Equality operators Compare values

!=, !== Inequality operators Compare values for inequality

<<, >>, >>> Bit shift operators Shift bits left or right

?…?…? Conditional (ternary) operator Decides which expression to execute based on a condition

= Assignment operator Assigns a value to a variable

% Remainder operator Finds the remainder of division

= Addition assignment operator Adds a value to a variable

&&=, ||=, ??= Logical assignments Perform logical operations and assign the result

<<=, >>=, >>>=, &=, ^=, |= Bitwise assignments Perform bitwise operations and assign the result

, Comma operator Evaluates multiple expressions in sequence

{…} Blocks Encloses statements

{…} Object literal syntax Encloses key-value pairs

var, let, const Declares variables with varying scope

label: Labels Marks a statement for use with break or continue

123n BigInt Represents an integer greater than the limit of regular numbers

# Private methods or private fields Defines private members of a class

The above is the detailed content of What JavaScript Symbols and Operators Do You Need to Know?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template