Function with namespace
by queryj
JavaScript
var test = {};
test.add = function (x, y) {
if (typeof x === "number" && typeof y === "number") {
return x + y;
} else {
return "undefined";
}
};
$(function () {
var $ = function (name) {
console.log(name, ": yes that's a dollar sign");
};
$("Tom");
var sum = test.add(1, 2);
console.log(sum + " is the sum.");
sum = test.add("tom", "239");
console.log(sum + " is the sum.");
});