javaScript 基础知识汇总 (十)】的更多相关文章

1.New Function 语法:let func = new Function ([arg1[, arg2[, ...argN]],] functionBody) //无参数示例: let sayHi = new Function('alert ("Hello")'); sayHi();//Hello //有参数示例 let sum = new Function('a','b','return a + b'); alert(sum(1,2));//3 2.调度:setTimeout…
1.属性的标志和描述符 属性的标志 对象属性除value外还有三个特殊属性,即标志 writable ----如果为true,则可以修改,否则它只是只读的. enumerable ----如果为true,则可在循环中列出,否则不列出. configurable -----如果为true,则此属性可以被删除,相应的特性也可以被修改,否则不可以 得到这些标志的语法: let descriptor = Object.getOwnPropertyDescriptor(obj,propertyName);…
1.模块简介 什么是模块: 模块就是一个文件,一个脚本,通过关键字export 和 import 交换模块之间的功能. export 关键字表示在当前模块之外可以访问的变量和功能. import 关键字允许从其他模块中导入一些诸如函数之类的功能. 使用示例: 文件 say.js export function sayHi(user) return `Hello ,${user}!`; } 文件index.html <!doctype html> <script type="mo…
1.回调 什么是回调? 个人理解,让函数有序的执行. 示例: function loadScript(src,callback){ let script = document.createElement('script'); script.src = src; script.onload =()=>calllback(script); document.head.append(script); } loadScript('src',script=>{ alert('ok'); }); 也可以在…
1. 图片热区: <img src="logo.jpg" usemap="#logo"> <map id="logo" name="logo"> <area shape="rect" coords="0,0,50,50" href="#"> </map> </img> 2. SetTimeout:只执行一次…
1.循环:while 和 for while 循环 while(condition){ //代码 循环体 } do ... while  循环 let i =0; do { //循环体 }while(condition) let i = 0; do{ alert(i); i++; }while(i) for 循环 for(begin;condiion;step){ //循环体 } for(let i = 0; i ; i++){ alert(i); } 省略语句段 for 循环 的begin语句…
1.基本类型与对象的区别 基本类型:是原始类型的中的一种值. 在JavaScript中有6中基本类型:string number  boolean  symbol  null  undefined 对象类型:能够存储多个值作为属性 可以使用大括号{}创建对象,例如:{name:"xiao",age:23}..JavaScript中还有其他种类的对象,例如函数就是对象. 2.作为对象的基本类型 1)基本类型仍然是原始数据,如预期相同,提供单个值 2)JavaScript允许访问字符串数字…
1.垃圾回收 JavaScript 的内存管理是自动的,不能强制执行或者阻止执行 可达性 JavaScript中主要的内存管理概念是可达性. 什么是可达性? 定义一个对象 let user = { name:"XiaoMing" }; user 应用了这个对象. 通过 user.name 可以取到“XiaoMing"这个值,则认为XiaoMing这个值是可达的. 当 user= null:  ”XiaoMing“ 这个值就不可达了,此时JavaScript的垃圾回收机制就会自…
1.运算符 术语或者叫法:一元运算符.二元运算符.运算元(参数) let x=0; x=5+2; //5和2为运算元,“+” 为二元运算符: x=-x; //"-" 为一元运算符 字符串连接功能,二元运算符 + 示例: let s = "my" + "string"; alert(s); // mystring alert( '1' + 2 ); // "12" alert( 2 + '1' ); // "21&qu…
1.<script> 标签 1) 可以通过<script> 标签将javaScript 代码添加到页面中 (type 和language 属性不是必须的) 2)外部的脚本可以通过 <script src="path/*.js" > </script> 这种方式插入 示例1: <!DOCTYPE HTML> <html> <body> <p>script 标签之前...</p> &…