Frontend Language Cheatsheet
My cheatsheet to Dart & JavaScript/TypeScript
TLDR - This is a cheatsheet of frontend programming languages, mainly JavaScript/TypeScript and Dart. Contents are indexed (in alphabetical order) and served in Chinese or English. If you are interested in this document, you can get started by checking the Keywords.
摘要 - 本文是我对前端开发语言(主要以JavaScript/TypeScript与Dart为主)。文章的内容将以类似词典的结构(首字母排序)以中英文列出,如果您对本文感兴趣,可以从关键词列表章节开始查看。
PROGRESS | 施工进度
KEYWORDS | 关键词列表
Variables | 变量
[General] Variable Declaration | 变量声明
| Language | Declaration keyword | Description |
|---|---|---|
| JavaScript | var |
Declare a global-scoped or function-scoped, re-assignable variable. 声明一个全局/函数域变量。 |
let |
Declare a block-scoped, re-assignable variable. 声明一个块级域变量。 |
|
const |
Declare a block-scoped constant which is not directly re-assignable; If the constant is an object, its properties can be updated. 声明一个块级域常量,常量无法重新赋值,但常量对象的属性可以被更改。 |
|
| Dart | varType-as-Declaration |
Declare a non-nullable, lexical-scoped variable. 声明一个不可null的动态域变量。 |
[Dart] Variable Declaration Modifiers | 变量声明修饰符
- Nullable modifier | 可null变量
<type>?: Declare a nullable variable. - Late modifier | 延迟声明变量
late <type>: Declare a [non-nullable] variable that is guaranteed to be initialised after its declaration, or lazy initialise a variable. - Constant | 常量
final/const: Declare a constant.
[General] Variable Types (Object as base class) | 变量类型(对象基础类)
In JavaScript/TypeScript, an Object represents the data type that stores a collection of properties as key-value pairs. It has the prototype of Object.prototype (which has the prototype of null) and can be created/initialised through three ways: the object initialiser {}, Object.create(), or the constructor function of a class with the new operator.
In Dart, the Object class is the base class for all Dart objects except null. It can be created/initialised through var or type-as-declaration.
[General] Variable Types (Primitives) | 变量类型(基础类型)
| Category | JavaScript/TypeScript | Dart | Description |
|---|---|---|---|
| Boolean | boolean / Boolean |
bool |
A Boolean value, either true or false. |
| Number | number / Numberbigint / BigInt |
intdouble |
An integer or floating point number. |
| String | string / String |
String |
A textual sequence. |
| Null | null |
null |
The absence of an object. (In JavaScript/TypeScript) typeof null == object |
| Symbol | symbol / Symbol |
- | A unique identifier. |
| undefined | undefined |
- | The absence of a value.typeof undefined == undefined |