<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<link rel="stylesheet" href="">
</head>
<body>
<script type="text/javascript">
function functionName(arg0, arg1, arg2) {
}
sayHi()
function sayHi() {
alert("hi")
}
var functionName = function(arg0, arg1, arg2) {
}
sayHi()
var sayHi = function() {
alert("hi")
}
if (condition) {
function sayHi() {
alert("hi")
}
} else {
function sayHi() {
alert("Yo!")
}
}
var sayHi
if (condition) {
sayHi = function() {
alert("hi")
}
} else {
sayHi = function() {
alert("Yo!")
}
}
function createComparisonFunction(propertyName) {
return function(object1, object2) {
var value1 = object1[propertyName];
var value2 = object2[propertyName];
if (value1 < value2) {
return -1
} else if (value1 > value2) {
return 1
} else {
return 0
}
}
}
function factorial(num) {
if (num < 1) {
return 1
} else {
return num * factorial(num - 1)
}
}
var anotherFactorial = factorial
factorial = null
alert(anotherFactorial(4))
function factorial(num) {
if (num < 1) {
return 1
} else {
return num * arguments.callee(num - 1)
}
}
var factorial = (function f(num) {
if (num < 1) {
return 1
} else {
return num * f(num - 1)
}
})
function createComparisonFunction(propertyName) {
return function(object1, object2) {
var value1 = object1[propertyName];
var value2 = object2[propertyName]
if (value1 < value2) {
return -1
} else(value1 > value2) {
return 1
} else {
return 0
}
}
}
function compare(value1, value2) {
if (value1 < value2) {
return -1
} else if (value1 > value2) {
return 1
} else {
return 0
}
}
var result = compare(5, 10)
function createFunctions() {
var result = new Array()
for (var i = 0; i < 10; i++) {
result[i] = function() {
return i
}
}
return result
}
createFunctions()
function createFunctions() {
var result = new Array()
for (var i = 0; i < 10; i++) {
result[i] = function(num) {
return function() {
return num
}
}(i)
}
return result
}
var name = "The Window"
var object = {
name: "My Object",
getNmaeFunc: function() {
return function() {
return this.name
}
}
}
console.log(object.getNmaeFunc()())
var name = "The Window"
var object = {
name: "My Object",
getNameFunc: function() {
var that = this
return function() {
return that.name
}
}
}
console.log(object.getNmaeFunc()())
var name = "The Window"
var object = {
name: "My Object",
getName: function() {
return this.name
}
}
object.getName()
(object.getName)()
(object.getName = object.getName)()
function assignHandler() {
var element = document.getElementbyId("someElement")
element.onclick = function() {
alert(element.id)
}
}
function assignHandler() {
var element = document.getElementbyId("someElement")
var id = element.id
element.onclick = function() {
alert(id)
}
element.null
}
function outputNumbers(count) {
for (var i = 0; i < count; i++) {
alert(i)
}
alert(i)
}
(function() {
})()
var someFuncton = function() {
}
someFuncton()
function() {
}()
(function() {
})()
function outputNumbers(count) {
(function() {
for (var i = 0; i < count; i++) {
alert(i)
}
})()
alert(i)
}
(function() {
var now = new Date()
if (new.getMonth() == 0 && now.getDate() == 1) {
alert("Happy new Year")
}
})()
function add(num1, num2) {
var sum = num1 + num2;
return sum
}
function MyObject() {
var privateVariable = 10
function privateFunction() {
return false
}
this.publicMethod = function() {
privateVariable++
console.log(privateVariable)
return privateFunction();
}
}
var instance = new MyObject()
function Person(name) {
this.getName = function() {
return name
}
this.setName = function(value) {
name = value
}
}
var person1 = new Person("Nicholas");
person1.getName()
person1.setName("Greg")
person1.getName()
(function() {
var privateVariable = 10;
function privateFunction() {
return false
}
MyObject = function() {
};
MyObject.prototype.publicMethod = function() {
privateVariable++
return privateFunction();
}
})()
(function() {
var name = '';
Person = function(value) {
name = value
}
Person.prototype.getName = function() {
return name
}
Person.prototype.setName = function(value) {
name = value
}
})()
var person1 = new Person("Nicholas");
person1.getName()
person1.setName("Greg")
person1.getName()
var person2 = new Person("Michael");
person1.getName()
person2.getName()
var singleton = {
name: value,
method: function() {
}
}
var singleton = function() {
var privateVariable = 10;
function privateFunction() {
return false;
}
return {
publicProperty: true,
publicMethod: function() {
privateVariable++;
return privateFunction()
}
}
}
var instance = new singleton()
var application = function() {
var components = new Array()
return {
getComponentCount: function() {
return components.length
},
registerComponent: function(component) {
if (typeof component == "object") {
components.push(component)
}
}
}
}
var singletion = function() {
var privateVariable = 10;
function privateFunction() {
return false;
}
CustomType = function() {}
var object = new CustomType()
object.publicProperty = true;
object.publicMethod = function() {
privateVariable++;
return privateFunction()
}
return object;
}()
var application = function() {
var components = new Array()
var BaseComponent = function() {
}
components.push(new BaseComponent())
var app = new BaseComponent()
app.getComponentCount = function() {
return components.length
}
app.registerComponent = function(component) {
if (typeof component == "object") {
components.push(component)
}
}
return app
}()
</script>
</body>
</html>