the example on javascript reference array.protorype.push() is confusing...

RESOLVED FIXED

Status

developer.mozilla.org
General
RESOLVED FIXED
4 years ago
4 years ago

People

(Reporter: manan.vaghasiya, Unassigned)

Tracking

Details

(Whiteboard: [specification][type:change], URL)

(Reporter)

Description

4 years ago
What feature should be changed? Please provide the URL of the feature if possible.
==================================================================================
the example is something like this...on url https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push

------------------------------------------

var sports = ["soccer", "baseball"];
var push = sports.push("football", "swimming");

console.log(sports); // ["soccer", "baseball", "football", "swimming"]
console.log(push);   // 4

-----------------------------------------

in this example has a variable called push and it is a valid javascript syntex but I found it bit confusing and any js newcomer would too as the variable name is same as the function name when you console.log it, it becomes confusing.

What problems would this solve?
===============================
It would be great if the variable changed to some other name so it will be easy to understand.

Who would use this?
===================
whoever wants to learn javascript array.

What would users see?
=====================
var sports = ["soccer", "baseball"];
var count = sports.push("football", "swimming");

console.log(sports); // ["soccer", "baseball", "football", "swimming"]
console.log(count);   // 4

What would users do? What would happen as a result?
===================================================
it would be pretty neat and understandable example.

Is there anything else we should know?
======================================
(Reporter)

Comment 1

4 years ago
If possible I would like to contribute it, so tell me if I can help with it.
(In reply to manan.vaghasiya from comment #1)
> If possible I would like to contribute it, so tell me if I can help with it.

Sure, please update the wiki page like you proposed. Do you need any help with that?
This page should get you started https://developer.mozilla.org/en-US/docs/Project:MDN/Contributing/Getting_started
Flags: needinfo?(manan.vaghasiya)
(Reporter)

Comment 3

4 years ago
Thanks Florian for guidance, I made changes on wiki page and is under technical review. Thanks.
Flags: needinfo?(manan.vaghasiya)
Thank you! Looks good to me, marked as reviewed.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.