pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Operators/Grouping

ranscend-cdn.com/cm/d556c3a1-e57c-4bdf-a490-390a1aebf6dd/airgap.js" >

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

Оператор группировки

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since июль 2015 г..

Оператор группировки ( ) контролирует порядок выполнения в выражениях.

Интерактивный пример

console.log(1 + 2 * 3); // 1 + 6
// Expected output: 7

console.log(1 + 2 * 3); // 1 + 6
// Expected output: 7

console.log((1 + 2) * 3); // 3 * 3
// Expected output: 9

console.log(1 * 3 + 2 * 3); // 3 + 6
// Expected output: 9

Синтаксис

 ( )

Описание

Оператор группировки из пары круглых скобок вокруг выражения или подвыражения, переопределяющего нормальный приоритет операторов, так что выражения с меньшим приоритетом выполняются раньше выражений с большим.

Примеры

Переопределяем порядок, когда сначала выполняется умножение и деление, а потом сложение и вычитание, чтобы сначала выполнить сложение.

js
let a = 1;
let b = 2;
let c = 3;

// обычный порядок
a + b * c; // 7
// выполнится так
a + (b * c); // 7

// теперь переопределим порядок
// сложение будет до умножения
(a + b) * c; // 9

// что эквивалентно следующему
a * c + b * c; // 9

Спецификации

Specification
ECMAScript® 2027 Language Specification
# sec-grouping-operator

Совместимость с браузерами

Смотрите также

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy