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


4 years ago
4 years ago


(Reporter: manan.vaghasiya, Unassigned)



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



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


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?

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
Flags: needinfo?(manan.vaghasiya)

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.
Last Resolved: 4 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.