Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

what is foo?

i always saw many programmer type in their code the word foo sometime as variable etc explain the word what is this ?

It's a fake word, used as a placeholder. You'll often see it paired with "bar", as in "foo bar". It's a programming term borrowed from the colorful old US military term "Fubar", which means--ahem--"fu*ked up beyond all recognition".

Ironically, In military slang, it means something (or someone, etc.) that's utterly broken or unusable.

3 Answers

Simon Woodard
Simon Woodard
6,545 Points

It doesn't mean anything, it's a term used because the variable isn't important to the lesson, but the complete code is. In working code 'foo' would never be used

Chris Malcolm
Chris Malcolm
2,909 Points

they're just placeholders..interesting stuff about their history though! http://en.wikipedia.org/wiki/Foobar

James Barnett
James Barnett
39,199 Points

The definitive answer on the history of foo RFC3092

James Barnett
James Barnett
39,199 Points

In computer science, programmers use metasyntactic variables to describe a placeholder name or an alias term commonly used to denote the subject matter under discussion or an arbitrary member of a class of things under discussion. The use of a metasyntactic variable is helpful in freeing a programmer from creating a logically named variable, which is often useful when creating or teaching examples of an algorithm. The word foo is the principal example.

from: https://www.princeton.edu/~achaney/tmve/wiki100k/docs/Metasyntactic_variable.html