Closed Bug 956505 Opened 10 years ago Closed 10 years ago

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

Categories

(developer.mozilla.org Graveyard :: General, defect)

All
Other
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: manan.vaghasiya, Unassigned)

References

()

Details

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

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?
======================================
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)
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
Closed: 10 years ago
Resolution: --- → FIXED
Product: developer.mozilla.org → developer.mozilla.org Graveyard
You need to log in before you can comment on or make changes to this bug.