Tuesday, July 24, 2012

[javascript] how to declare private variable

ref: http://www.w3schools.com/js/js_functions.asp

Situation 1 (Private)
function foobar(){
  var foo =1;
  alert foo;
}
// will alert 1
foobar();
// will alert undefined
alert(foo);


Situation 2 (Public)
function foobar(){
  foo =1; // no var declared. it is public
  alert foo;
}
// will alert 1
foobar();
// will alert 1
alert(foo);

* Can u spot the difference?


The Lifetime of JavaScript Variables

If you declare a variable, using "var", within a function, the variable can only be accessed within that function. When you exit the function, the variable is destroyed. These variables are called local variables. You can have local variables with the same name in different functions, because each is recognized only by the function in which it is declared.
If you declare a variable outside a function, all the functions on your page can access it. The lifetime of these variables starts when they are declared, and ends when the page is closed.

Tuesday, July 03, 2012

ngrep.

Tools
- OpenVPN server
- ngrep
- tcpdump
- strings
- awk
- sort

command:
Code:
ngrep -q -W byline (mybbuser)|(Cookie) dst port 80 -O test2.txt

Related Posts Plugin for WordPress, Blogger...