当前位置:网站首页>Typescript namespace
Typescript namespace
2022-06-11 07:59:00 【YY little monster】
Details visible
1. What is a namespace ?
A namespace can be seen as a tiny module ,
When we first write the relevant business code together , When you don't want to pollute the global space , We can use namespaces
The essence is to define a large object , Put variables / Method / class / Interface ... Put everything in it
2. Namespace is different from module
Code used inside the program , You can use namespaces to encapsulate and prevent global pollution
Code used inside and outside the program , Modules can be used to encapsulate and prevent global contamination
summary : Because the module can also realize the same function , So in most cases, you can use modules
namespace Validation {
const lettersRegexp = /^[A-Za-z]+$/;
export const LettersValidator = (value) =>{
return lettersRegexp.test(value);
}
}
console.log(Validation.LettersValidator('abc'));
console.log(Validation.LettersValidator(123));
Methods that call namespaces from other locations
./56/test.ts
namespace Validation {
const lettersRegexp = /^[A-Za-z]+$/;
export const LettersValidator = (value) =>{
return lettersRegexp.test(value);
}
}
/// <reference path="./56/test.ts" />
console.log(Validation.LettersValidator('abc'));
console.log(Validation.LettersValidator(123));
边栏推荐
- Pycrypto packaging error
- C language lesson 2
- C. Manipulating History(贪心/哈希/思维/好题)
- Simple use of string
- Layout of code setting constraintlayout_ constraintDimensionRatio
- 【 史上最全的ENSP【安装图解】!】
- Semiconductor memory classification
- [atcoder1983] BBQ hard (combination number + clever model transformation)
- TypeScript-声明合并
- Space geometry
猜你喜欢
![[atcoder2306] rearranging (topology)](/img/b3/38589a07a7c26bea8ed154ab794760.png)
[atcoder2306] rearranging (topology)

Bladed入門教程(視頻)

Qunhui ds918 creates m.2 SSD read / write cache

Xshell7 和 Xftp7要继续使用此程序,您必须应用最新的更新或者使用新版本

Training yolov4 CSP model using coco dataset

Bubble sorting with C language

安卓初中级开发基础知识整理(面试自用)

mpi

Image data enhancement (translation, rotation, brightness transformation, flipping, adding Gaussian noise, scaling, cropping)

【案例解读】医疗单据OCR识别助力健康险智能理赔
随机推荐
Remote office experience | community essay solicitation
Training yolov4 CSP model using coco dataset
C language to achieve a simple game - minesweeping
Xshell7 and xftp7 to continue using this program, you must apply the latest updates or use a new version
Dameng database startup and shutdown
放大镜子效果图
使用 COCO 数据集训练 YOLOv4-CSP 模型
TypeScript-类型保护
Logical implication of functional dependence
Receive ontrimmemory and other callbacks through componentcallbacks2 and mock the corresponding scenario
How to find the complementary sequence of digraph
Sort - Swap sort
Alchemy experience (model training of deep learning) the necessity of timely adjusting training parameters for some situations (the adjustment of learning rate LR is the primary) summarizes some metho
TypeScript-在koa中配置TS和使用koa-router
Servlet
【案例解读】医疗单据OCR识别助力健康险智能理赔
TypeScript-类型别名
SOCKET【5】- struct linger 用法
Shell Programming Notes
TiDB Cloud 上线 Google Cloud Marketplace,以全新一栈式实时 HTAP 数据库赋能全球开发者