Number as a variable name in javascript
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 fro开发者_开发知识库m 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 .. ?
That's not a variable, that's an expression.
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.
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
精彩评论