1
01. (function(){
02. function b(e){if(!d[e]){var f=d[e]={exports:{}};c[e].call(f.exports,a,f,b)}
03. return d[e].exports
04. }
05. var a=this,c=b.modules=[],d=b.cache=[];
06. c[0]=function(a,b,c)
07. {
08. var d=this;
09. 1;
10. var e=c(1),g=c(3).Builder,h=c(11);var i=c(10);
11. var j=c(15).Circle;var k = c(17).Friend; 
12. l=c(18).SearchFriends;c(19);

This is an fb app code that i have copied from fb friend circles, i am working in a different manner but was going through this script,where

FUNCTION c[0] has a variable 1 in it ...


How can bare numbers be used as variable names in javascript .. ?

3
  • possible duplicate of Valid Characters for JavaScript Variable Names Commented Jul 3, 2011 at 22:56
  • c() is a function on lines 10-12, passed in on line 6 (third parameter), the number is just a parameter to that function. Commented Jul 3, 2011 at 22:58
  • @Dan D. dude that is an expression or a type it is not a duplicate of any other topic.. such a question has never been asked ..!! Commented Jul 3, 2011 at 23:23

3 Answers 3

2

That's not a variable, that's an expression.

Sign up to request clarification or add additional context in comments.

2 Comments

please elaborate.. how this expression evaluates ..?does that expression mean function c[0] returns true always ..?
1 is an expression. so is 1+3. a couple of languages allow using expressions without actually using them (without assigning them to something or using them as a call parameter to a function, etc...). It's a no-operation
2

Javascript variable names must begin with a letter or underscore or $. They may contain numbers, but not start with a number.

The statement you asked about:

1;

is a no-op. It's an expression that evaluates to a value of one, but since it isn't assigned to anything, it doesn't do anything. It doesn't declare a variable. Chances are it's a typo of some kind in the source you started with.

4 Comments

Variable names may also begin with $.
{view:"DetailCard",id:"card",pos:"w:88px h:95px",visible:!1} the expression has also been used inside the json array, may be its a boolean but it does appear like an expression
@Nina. What is your question about that code? That is an object declaration that has attributes o.view, o.id, o.pos and o.visible.
i posted {//json content goes here} because the strange expression or variable is possibly also used inside the json, may be i am wrong
-1

They are not numbers, they are function calls.
For example, if you have

function c(num){
  if(num == 10) return "Edgar";
}

when you do:

c(10)

You get "Edgar" (the function evaluation).
Hope this helps. Cheers

1 Comment

:) i asked about the variable/expression/typo inside the function c[0]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.