Mac OS X 配置指南

Mac OS X 配置指南

  • Docs
  • Blog

notes/javascript/typescript

Typescript

基本类型

数字(Number)、布尔(Boolean)、字符串(String)、数组(Array)、Tuple、 Never、枚举(Enum)、Any、Void、Null。

Notes: Void 常用作函数的返回值。

eg.

function name():void {
 // something here
}

error handling

  • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch

一般的格式为

try {

} catch(e) {

} finally {

}

How to handle "unhandled Promise rejections" #72

  • https://github.com/tc39/ecmascript-asyncawait/issues/72

TIPS:

老版本的 javascript 里,定义类的方法是有三种

  • https://www.phpied.com/3-ways-to-define-a-javascript-class/

Function

  • 在内部声明 method:
function Apple(type) {
   this.type = type;
   this.color = "red";
   this.getInfo = function() {
      alert(this.color+" "+this.type)
   } 
  • 在外部声明 method:
function Apple(type) {
   this.type = type;
   this.color = "red";
}

Apple.prototype.getInfo = function() {
   alert(this.color+" "+this.type)
}

Object

apple = {
   type: "Mac"
   color: "Red"
   getInfo: function() {
      alert(this.color+" "+this.type)
   }
}

Singleton Object using function (通常译作单例)

把上面的两种情况结合起来就好了。

apple = function() {
  // somethimg
}
Last updated on 2019-1-8 by wild-flame
  • 基本类型
  • error handling
  • TIPS:
Docs
Mac OS 配置指南 | Mac OS Setup Guide乱七八糟的笔记
Projects
Leetcode solutionsJekyll simple猪瘟疫情可视化
More
BlogGitHub
Copyright © 2019 wild-flame