Javascript hoisting

In JavaScript, a name enters a scope in one of four basic ways (and in this order):
1. Language-defined: All scopes are, by default, given the names 'this' and 'arguments'.
2. Formal parameters: Functions can have named formal parameters, which are scoped to the body of that function.
3. Function declarations: These are of the form function foo() {}.
4. Variable declarations: These take the form var foo;.


Function declarations and variable declarations are always moved ("hoisted") invisibly to the top of their containing scope by the JavaScript interpreter.

The assignment portion of the declarations were not hoisted. Only the name is hoisted. Actual assignment to the variable name waits at its own line. This is not the case with function declarations, where the entire function body will be hoisted as well.

While hoisting, if a function name has already been defined, it is never overridden by another variable of the same name. This means that a function declaration takes priority over a variable declaration. This does not mean that an assignment to that variable name will not work, just that the declaration portion will be ignored while hoisting takes place. Since actual assignment to the variable name waits at its own line, after assignment the variable name (and its behavior) hides/overrides the function name.

Example:

1.
function example()
{
foo(); // TypeError "foo is not a function"
bar(); // valid
baz(); // TypeError "baz is not a function"
spam(); // ReferenceError "spam is not defined"
var foo = function () {}; // anonymous function expression (only 'foo' gets hoisted)
function bar() {}; // function declaration ('bar' and the function body get hoisted)
var baz = function spam() {}; // named function expression (only 'baz' gets hoisted)
foo(); // valid
bar(); // valid
baz(); // valid
spam(); // ReferenceError "spam is not defined"
}

2.
<script type="text/javascript">
document.write( f(3) + "<br/>")
var f=function(x) { return x+1; }
function f(x) { return x+2; }
document.write( f(3) + "<br/>")
</script>

This code is equivalent to:

<script type="text/javascript">
function f(x) { return x+2; }
var f; //until assignment this declaration doesn't change behavior of f()
document.write( f(3) + "<br/>")
f=function(x) { return x+1; } //after this assignment, behavior of old f() gets lost
document.write( f(3) + "<br/>")
</script>


Source: http://www.adequatelygood.com/JavaScript-Scoping-and-Hoisting.html

Create iso file from CD/DVD using Linux dd command

# isoinfo -d -i /dev/cdrom | grep -i -E 'block size|volume size'
Logical block size is: 2048
Volume size is: 327867

# dd if=/dev/cdrom of=/path/to/my.iso bs=<block size from above> count=<volume size from above>

Source: https://www.thomas-krenn.com/en/wiki/Create_an_ISO_Image_from_a_source_CD_or_DVD_under_Linux

Almost self printing Javascript program

<script type="text/javascript">
( function f() { document.write( f ) }() )
</script>