/typescript/

TypeScript part 24 (namespace)

2017-03-04 21:54:14

TypeScript

namespace StrUtil {
    export function connect(str1: string, str2: string): string {
        return str1 + str2;
    }
}

namespace NumUtil {
    export function add(num1: number, num2: number): number {
        return num1 + num2;
    }
}

console.log(StrUtil.connect("Lorem", "Ipsum"));
console.log(NumUtil.add(25, 25));

JavaScript

var StrUtil;
(function (StrUtil) {
    function connect(str1, str2) {
        return str1 + str2;
    }
    StrUtil.connect = connect;
})(StrUtil || (StrUtil = {}));
var NumUtil;
(function (NumUtil) {
    function add(num1, num2) {
        return num1 + num2;
    }
    NumUtil.add = add;
})(NumUtil || (NumUtil = {}));
console.log(StrUtil.connect("Lorem", "Ipsum"));
console.log(NumUtil.add(25, 25));