苹果手机 上不了网 wifi网络 自动获取 获取ip 上网方式
网站首页不能上网路由器密码 WiFi设置 路由器设置TP-Link 腾达路由器软件教程游戏教程系统下载
时间:2024/6/3作者:未知来源:争怎路由网人气:
与 js 的基本数据类型类似,包括:
boolean: 对应 js 的 Boolean 类型
number: 对应 js 的 Number 类型
string: 对应 js 的 String 类型
null: 对应 js 的 null
void: 对应 js 的 undefined
正常的 js 代码
let hello = 'hello'; // 声明一个变量 hello = 2 * 2; // 重新赋值 hello = []; // 重新赋值
加上 flow 静态类型检查扩展的代码
// @flow let hello: string = 'hello'; // 声明一个 string 类型的变量 hello = 2 * 2; // 报错 hello = []; // 报错 hello = 'hi'; // 重新赋值1.2 函数正常的 js 代码function plus(a, b) { return a + b; } plus(); // NaN plus(1); // NaN plus(1, 2); // 3 plus('hello'); // 'helloundefined' plus('hello', ' hi'); // 'hello hi' plus({}, {}); // '[object Object][object Object]'加上 flow 静态类型检查扩展的代码// @flow // 定义一个 '两个数字参数,返回值也是数字' 的函数 function plus(a: number, b: number): number { return a + b; } plus(); // 报错 plus(1); // 报错 plus('hello'); // 报错 plus('hello', ' hi'); // 报错 plus({}, {}); // 报错 plus(1, 2); // 31.3 可能(Maybe),可选(Optional),语义(Literal),混合(Mixed)可能(Maybe)类型用一个 ? 在类型前面表示,包含类型本身、null、undefined// @flow let hello: ?string; // 声明一个数据类型可以是 string, null, undefined 的变量 hello = null; // 赋值 hello = undefined; // 重新赋值 hello = 'hello'; // 重新赋值 hello = 1; // 报错 hello = true; // 报错可选(Optional)类型一般用于对象属性或者函数参数,在名称后面加一个 ?,包含类型本身、undefined// @flow const obj: {hello? : string}; // 属性 hello 可以是 string, undefined obj = {}; // 赋值 obj = {hello: undefined}; // 重新赋值 obj = {hello: 'hello'}; // 重新赋值 obj = {hello: null}; // 报错 obj = {hello: 1}; // 报错 obj = {hello: true}; // 报错 // 属性 param 可以是 number, undefined function method(param?: number) { /* ... */ } method(); // 正常 method(undefined); // 正常 method(1.12); // 正常 method(null); // 报错 method('hello'); // 报错语义(Literal)类型一般用于声明某个,某几个特定的值(多个值用 关键词:javascript的扩展:如何运用flow静态分类进行检查报错
function plus(a, b) { return a + b; } plus(); // NaN plus(1); // NaN plus(1, 2); // 3 plus('hello'); // 'helloundefined' plus('hello', ' hi'); // 'hello hi' plus({}, {}); // '[object Object][object Object]'加上 flow 静态类型检查扩展的代码// @flow // 定义一个 '两个数字参数,返回值也是数字' 的函数 function plus(a: number, b: number): number { return a + b; } plus(); // 报错 plus(1); // 报错 plus('hello'); // 报错 plus('hello', ' hi'); // 报错 plus({}, {}); // 报错 plus(1, 2); // 31.3 可能(Maybe),可选(Optional),语义(Literal),混合(Mixed)可能(Maybe)类型用一个 ? 在类型前面表示,包含类型本身、null、undefined// @flow let hello: ?string; // 声明一个数据类型可以是 string, null, undefined 的变量 hello = null; // 赋值 hello = undefined; // 重新赋值 hello = 'hello'; // 重新赋值 hello = 1; // 报错 hello = true; // 报错可选(Optional)类型一般用于对象属性或者函数参数,在名称后面加一个 ?,包含类型本身、undefined// @flow const obj: {hello? : string}; // 属性 hello 可以是 string, undefined obj = {}; // 赋值 obj = {hello: undefined}; // 重新赋值 obj = {hello: 'hello'}; // 重新赋值 obj = {hello: null}; // 报错 obj = {hello: 1}; // 报错 obj = {hello: true}; // 报错 // 属性 param 可以是 number, undefined function method(param?: number) { /* ... */ } method(); // 正常 method(undefined); // 正常 method(1.12); // 正常 method(null); // 报错 method('hello'); // 报错语义(Literal)类型一般用于声明某个,某几个特定的值(多个值用 关键词:javascript的扩展:如何运用flow静态分类进行检查报错
// @flow // 定义一个 '两个数字参数,返回值也是数字' 的函数 function plus(a: number, b: number): number { return a + b; } plus(); // 报错 plus(1); // 报错 plus('hello'); // 报错 plus('hello', ' hi'); // 报错 plus({}, {}); // 报错 plus(1, 2); // 31.3 可能(Maybe),可选(Optional),语义(Literal),混合(Mixed)可能(Maybe)类型用一个 ? 在类型前面表示,包含类型本身、null、undefined// @flow let hello: ?string; // 声明一个数据类型可以是 string, null, undefined 的变量 hello = null; // 赋值 hello = undefined; // 重新赋值 hello = 'hello'; // 重新赋值 hello = 1; // 报错 hello = true; // 报错可选(Optional)类型一般用于对象属性或者函数参数,在名称后面加一个 ?,包含类型本身、undefined// @flow const obj: {hello? : string}; // 属性 hello 可以是 string, undefined obj = {}; // 赋值 obj = {hello: undefined}; // 重新赋值 obj = {hello: 'hello'}; // 重新赋值 obj = {hello: null}; // 报错 obj = {hello: 1}; // 报错 obj = {hello: true}; // 报错 // 属性 param 可以是 number, undefined function method(param?: number) { /* ... */ } method(); // 正常 method(undefined); // 正常 method(1.12); // 正常 method(null); // 报错 method('hello'); // 报错语义(Literal)类型一般用于声明某个,某几个特定的值(多个值用 关键词:javascript的扩展:如何运用flow静态分类进行检查报错
可能(Maybe)类型用一个 ? 在类型前面表示,包含类型本身、null、undefined
// @flow let hello: ?string; // 声明一个数据类型可以是 string, null, undefined 的变量 hello = null; // 赋值 hello = undefined; // 重新赋值 hello = 'hello'; // 重新赋值 hello = 1; // 报错 hello = true; // 报错可选(Optional)类型一般用于对象属性或者函数参数,在名称后面加一个 ?,包含类型本身、undefined// @flow const obj: {hello? : string}; // 属性 hello 可以是 string, undefined obj = {}; // 赋值 obj = {hello: undefined}; // 重新赋值 obj = {hello: 'hello'}; // 重新赋值 obj = {hello: null}; // 报错 obj = {hello: 1}; // 报错 obj = {hello: true}; // 报错 // 属性 param 可以是 number, undefined function method(param?: number) { /* ... */ } method(); // 正常 method(undefined); // 正常 method(1.12); // 正常 method(null); // 报错 method('hello'); // 报错语义(Literal)类型一般用于声明某个,某几个特定的值(多个值用 关键词:javascript的扩展:如何运用flow静态分类进行检查报错
可选(Optional)类型一般用于对象属性或者函数参数,在名称后面加一个 ?,包含类型本身、undefined
// @flow const obj: {hello? : string}; // 属性 hello 可以是 string, undefined obj = {}; // 赋值 obj = {hello: undefined}; // 重新赋值 obj = {hello: 'hello'}; // 重新赋值 obj = {hello: null}; // 报错 obj = {hello: 1}; // 报错 obj = {hello: true}; // 报错 // 属性 param 可以是 number, undefined function method(param?: number) { /* ... */ } method(); // 正常 method(undefined); // 正常 method(1.12); // 正常 method(null); // 报错 method('hello'); // 报错语义(Literal)类型一般用于声明某个,某几个特定的值(多个值用 关键词:javascript的扩展:如何运用flow静态分类进行检查报错
语义(Literal)类型一般用于声明某个,某几个特定的值(多个值用 关键词:javascript的扩展:如何运用flow静态分类进行检查报错
关键词:javascript的扩展:如何运用flow静态分类进行检查报错
Copyright © 2012-2018 争怎路由网(http://www.zhengzen.com) .All Rights Reserved 网站地图 友情链接
免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!
QQ:1006262270 邮箱:kfyvi376850063@126.com 手机版