01- Built-in objects
/ /! Built-in objects
(() = > {
/ /? 1. ECMAScript built-in objects
let b: Boolean = new Boolean(1);
let n: Number = new Number(true);
let s: String = new String("abc");
let d: Date = new Date(a);let r: RegExp = / / ^ 1;
let e: Error = new Error("error message");
b = true;
// let bb: boolean = new Boolean(2) // error
/ /? 2. Built-in objects for BOM and DOM
const div: HTMLElement | null = document.getElementById("test");
const divs: NodeList = document.querySelectorAll("div");
document.addEventListener("click".(event: MouseEvent) = > {
console.dir(event.target);
});
const fragment: DocumentFragment = document.createDocumentFragment(); }) ();Copy the code
02- Declaration document
import jQuery from "jquery";
/ /! Introduce the third-party library JQ
//import jQuery from "jquery";
//jQuery(" selector ");
/** ** When using a third-party library, we need to reference its declaration file to obtain the corresponding code completion, interface prompts and other functions. Declare var jQuery: (selector: string) => any; var selector: (selector: string) => any; * * Declaration file: Put declaration statements in a separate file (jquery.d.ts), ts will automatically parse to all declaration files in the project * * Download declaration file: NPM install@types/jquery --save-dev
*/
jQuery("Selector");
Copy the code