Похожие чаты

What is the best way to make it clear what

a function parameter does? E.g a function getList(optParameter) and I want to add a parameter that returns a somewhat different list. so in the call it could end up being getList(true) which is horrible since there's no way to tell what true parameter does. config obj?

3 ответов

9 просмотров

Sounds like you want a second function

Create a const for the boolean parameter: const includeDates = true; const result = getList(includeDates) Also, use JS Docs to make it clear what a parameter does. Another option is making a "private" function that takes the parameter, and other two "public" functions that handles that paramater: /** * @param { boolean | undefined } includeDates description */ function getList(includeDates) { ... } function getListWithDates() { return getList(true); } function getListWithoutDates() { return getList() }

Bruno- Автор вопроса
Alejandro Rivera
Create a const for the boolean parameter: const i...

forgot to thank you btw, that's a good solution

Похожие вопросы

Обсуждают сегодня

А кто-то пробовал, уезжая из Эстонии получить э-рез и продолжить вести предпринимательскую деятельность внутри Эстонии, используя свой OÜ?
Lalalashechki Lalala
57
@MrMiscipitlick А можешь макрос написать, который будет вычислять смещение относительно переданных меток? Просто .label1-.label2, и вернуть значение.
КТ315
35
я не магистр хаскеля, но разве не может лейзи тип конвертнуться в не-лейзи запросив вычисление содержимого прям при инициализации?
deadgnom32 λ madao
100
А еще в перле можно уже @arr1 + @arr2?
Sergei Zhmylove
53
Подобного рода ;Следующие три строки это директивы ассемблера, ;которые можно не задавать, т.к.работаем в Visual Studio. ;Символ ";" - это начало однострочного комментария ...
Егор Анелькин
3
I arrived here after a Chico Crypto show highlighted the project & the Team - the fact that the Team had a long history of successfully working with household names gave me e...
Banter is Bullish
5
Dear super pioneers 🥳🥳: I want to purchase a hosting plan for a website where video games, metaverse, AI avatars, videos, and heavy virtual twins can be uploaded, which I wan...
Guapi
10
Привет всем. появился вопрос. Разрабатываю сайт, в данный момент он запущен. Хостинг beget. Добавляю на сайт яндекс метрику с помощью полей client-settings (взято отсюда http...
Andrew
2
еще вопрос, допустим мы создадим char массив из 10 элементов и присвоим ему через сканф 10 символов. и выведем все символы. Хотел спросить последний элемент /0 будет включать...
Anthem
10
Подскажите, где смотреть результат выполнения программы? Код: ;.686 ;Система команд процессора 686 ;.MODEL FLAT,stdcall ;Модель памяти плоская, станда...
Егор Анелькин
5
Карта сайта