const x: number = 6, y: number = 3;
console.log("算术", x + y, x - y, x * y, x / y, x % y);
let before = 5; const old = before++;
let after = 5; const fresh = ++after;
console.log("递增", old, before, fresh, after);
console.log("比较", x > y, x < y, x === y, x !== y);
console.log("逻辑", x < 10 && y > 1, x === 5 || y === 5, !(x === y));
const a: number = 2, b: number = 3;
console.log("位", a & b, a | b, a ^ b, ~b, a << b, a >> b, a >>> 1);
let total = 12; const step = 10;
total = step; total += step; total -= step; total *= step; total /= step; total %= step;
console.log("连续赋值", total);
console.log("站点", "mbsky" + ".com");
本例需在 固定版本的TypeScript编译器,启用strict;编译产物在支持ES2022的JavaScript环境中运行 中运行,请复制源码、保存文件或下载工程包后在本地执行验证。
运行说明与环境独立工程
运行环境:固定版本的TypeScript编译器,启用strict;编译产物在支持ES2022的JavaScript环境中运行
入口文件:examples/43e84d4d285011d4afd09915/core/core.ts
预期结果与验证条件观察提示
- 算术:9、3、18、2、0
- 递增:5、6、6、6
- 比较:true、false、false、true
- 逻辑:true、false、true
- 位:2、3、1、-4、16、0、1
- 连续赋值最终0;站点mbsky.com
请结合实际环境逐项观察。
附件与关联工程包下载
课程关联工程包(登记关联72章) · 含当前章节或实例 · mbskycom202611a325.zip