Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the square brackets "[" and "]" from the syntax #3679

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nintendoit
Copy link
Contributor

In the syntax for array splice method, the square bracket should not be present.

In the syntax for array splice method, the square bracket should not be present.
@javascript-translate-bot javascript-translate-bot added the review needed Review needed, please approve or request changes label Mar 20, 2024
@javascript-translate-bot javascript-translate-bot requested a review from a team March 20, 2024 11:31
@nintendoit
Copy link
Contributor Author

Another question:

for slice syntax -> arr.slice([start], [end])
Do square bracket serve any special purpose here?

@joaquinelio
Copy link
Member

Another question:

for slice syntax -> arr.slice([start], [end]) Do square bracket serve any special purpose here?

It's an old convention for "optional".

Mmm...
Should be:
arr.slice( [start] [,end] )

@nintendoit
Copy link
Contributor Author

Ok, then the splice syntax is correct.But it do look confusing.

Should I

  • close this PR
    or
  • revert that change and make change to the slice syntax?

@smith558
Copy link
Member

smith558 commented Mar 21, 2024

Hi all, it should actually be arr.splice(start[, deleteCount, elem1, ..., elemN]), as it is. All parameters optional except of the first one. It's a GNU syntax of method signatures for documentations based on BNF. It's a bit obscure and not very beginner friendly, so I was already thinking whether we should adopt a different style such as the one MDN docs are using. Let's keep this open.

@joaquinelio
Copy link
Member

I like the brackets, the single line is more clear when you know the brackets purpose.
I suggested a font change just for the brackets. If you paint them gray and slightly bigger, your brain will recognize they are not part of the syntax.
Maybe the dots should be changed too.

But
Consider adopting MDN style.
MDN has influence in the community, a single convention would be user friendly.

@smith558
Copy link
Member

It may be worth creating a separate article on this syntax so that people can be introduced to it, or at least provide a link. Unfortunately there isn't much resources on this online, there seems to be no standard. The only relevant discussion about this I can find is https://stackoverflow.com/questions/10925478/how-to-interpret-function-parameters-in-software-and-language-documentation.

@joaquinelio
Copy link
Member

I'd stay with brackets.
Imagine that stackoverflow link example in mdn style.

After "manual and specifications"
Title
"Syntax conventions"
Body
"Square brackets mean optional"
Odd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review needed Review needed, please approve or request changes tell your opinion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants