Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
128
rated 0 times [  129] [ 1]  / answers: 1 / hits: 22590  / 12 Years ago, tue, july 10, 2012, 12:00:00

In this post, Nick Craver provided an answer in which he used:



function(_, id)


This code doesn't declare the underscore as a variable before using it. My search on google and on here only points to references to the use of the underscore as a prefix., not as the variable itself. What does it do? I like the solution by Nick but that bit bothers me.


More From » javascript

 Answers
102

I've seen the underscore used to denote that the variable is a don't care variable. It means that it doesn't matter and isn't used at all.



In the case you pointed out, it was used to signify that his function had two arguments, but he only needed the second one.


[#84365] Sunday, July 8, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
janjadonb

Total Points: 4
Total Questions: 114
Total Answers: 118

Location: Mali
Member since Fri, Dec 3, 2021
3 Years ago
janjadonb questions
;