Return value assignment in JavaScript/Web API syntax box

Looking at JavaScript methods that return a value, such as Array.prototype.find(), there are no assignments. (There were a few that has I think, but not much)

arr.find(params);         // without assignment
value = arr.find(params); // with assignment

On the other hand, methods from Web API have an assignment, such as Document.querySelectorAll():

elementList = parentNode.querySelectorAll(selectors);

Web API documents go further, and properties have syntax box too.

dnt = navigator.doNotTrack;

(from Navigator.doNotTrack)

For me, property syntax seems redundant, for both JavaScript and Web API. So Navigator.doNotTrack should change its Syntax to Description and remove syntax box.
I wouldn’t write method return value assignment neither, as there are #Syntax > #Return value, but might there be useful cases I didn’t think of?

[x, y] = getPos(element); // an example of useful cases... or not

But these are just my thoughts.

What caused these differences? Maybe something I don’t know but important one, such as differences between readers?
What should I do with JavaScript methods that have return value assignment, or with WebAPI methods that have no return value assignment? What of properties with Syntax section, instead of Description?

1 Like

I think the differences are largely based on the preferences of the writer who wrote the syntax box for that article.

Yeah, I think we still haven’t quite nailed down the way we prefer to write these, and there are some variations based on who wrote it.

1 Like