1. 多变量赋值
var lastname="Doe", age=30, job="carpenter";
var x,y,z=1;
var carname;//空值、
carnanme=null //清空原始值
https://www.runoob.com/js/js-variables.html
1. 声明变量类型,var carname=new String;
https://www.runoob.com/js/js-datatypes.html
1.对象创建一个大括号即可
https://www.runoob.com/js/js-obj-intro.html
1. 全局变量window
car=0 //创建
window.car//调用
https://www.runoob.com/js/js-scope.html
1. 比较,===,!==
非基础类型的比较时,==,===只比较是不是同一个对象的引用,而不比较比如数组a和数组b里面的值
https://www.runoob.com/js/js-comparisons.html
https://segmentfault.com/a/1190000016574183
1. break可跳出标签。
https://www.runoob.com/js/js-break.html
1. undefined 和 null 的区别, typeof
https://www.runoob.com/js/js-typeof.html
1.constructor用来判断信息类型,js全部类型
https://www.runoob.com/js/js-type-conversion.html
1. 一目+相当于Number()
y=+"5"//等价于y=Number("5")
https://www.runoob.com/js/js-type-conversion.html
1.正则表达式语法
/正则表达式主体/修饰符(可选)
https://www.runoob.com/js/js-regexp.html
1. 抛出异常
throw exception
exception可以是 JavaScript 字符串、数字、逻辑值或对象。
https://www.runoob.com/js/js-errors.html
1. 设置断点
debugger;
https://www.runoob.com/js/js-debugging.html
1. JS有hoisting(声明提升)+严格模式
严格模式下是不能使用全局变量的
严格模式下函数是没有绑定到 this 上,这时候 this 是 undefined。
函数也有提升,可以再定义函数前调用函数
箭头函数是不能提升的,所以需要在使用之前定义
https://www.runoob.com/js/js-hoisting.html
https://www.runoob.com/js/js-strict.html
https://www.runoob.com/js/js-this.html
函数提升:https://www.runoob.com/js/js-function-definition.html
1. 常规的比较中,数据类型是被忽略的==,===
https://www.runoob.com/js/js-mistakes.html
1. 如果是一个不完整的语句(没有;结尾)JavaScript 将尝试读取第二行的语句,return除外
https://www.runoob.com/js/js-mistakes.html
1. apply 和 call 允许切换函数执行的上下文环境(context),即 this 绑定的对象,可以将 this 引用到任何对象。
https://www.runoob.com/js/js-this.html
1.块级作用域 和 函数作用语意义居然不一样
例如 var x可只作用于函数,但不能只作用于块级
let就可以作用于函数和块级
https://www.runoob.com/js/js-let-const.html
1. void(表达式)会先执行表达式,然后整个void()返回undified
https://www.runoob.com/js/js-void.html
1. 但是子线程有一个局限:一旦发射了以后就会与主线程失去同步,我们无法确定它的结束,如果结束之后需要处理一些事情,比如处理来自服务器的信息,我们是无法将它合并到主线程中去的。为了解决这个问题,JavaScript 中的异步操作函数往往通过回调函数来实现异步任务的结果处理。
promise起始函数参数resolve和reject可自行命名
起始函数的resolve用于标记状态,跳入then中(实例化的promise才有then)
起始函数的reject用于标记状态,跳入catch中
then中的return用于跳入下一个then中
then中的throw用于跳入跳入catch中
then中部return或throw就无法结束
cathch中可以不return或throw
promise.then() 是 promise 最为常用的方法。promise.then(onFulfilled, onRejected)
promise简化了对error的处理,上面的代码我们也可以这样写:promise.then(onFulfilled).catch(onRejected)
https://www.runoob.com/js/js-promise.html
https://www.runoob.com/w3cnote/javascript-promise-object.html
https://www.jianshu.com/p/5b0b89bf4664
1. 函数再声明时可以自调用
(函数体)()
函数是对象,arguments.length 属性返回函数调用过程接收到的参数个数
https://www.runoob.com/js/js-function-definition.html
1. 变量声明时如果不使用 var 关键字,那么它就是一个全局变量,即便它在函数内定义。
https://www.runoob.com/js/js-function-closures.html
1. document.getElementById('p1').style.特征=新值
或一步赋值:
document.getElementById('test').style="background-color:#D94A38;width:120px;height:20px;padding:40px;"
改变css属性
https://www.runoob.com/js/js-htmldom-css.html
1. 函数作为对象使用,是直接func, 而不是 new func(),注意,这样就不能传递参数
传递参数的话需要 function() {func(p1,p2);}来使用;
所以,为了统一,通常都用function() {func();}的形式
1.新增属性和方法用.prototype属性
https://www.runoob.com/js/js-object-prototype.html
1.继承
function Teacher(first, last, age, gender, interests, subject) {
Person.call(this, first, last, age, gender, interests);
this.subject = subject;
}
//无参数继承
function BlueGlassBrick() {
Brick.call(this);
this.opacity = 0.5;
this.color = 'blue';
}
1.JS数字不分为整数类型和浮点型类型,所有的数字都是由 浮点型类型,浮点数运算不一定精准
1.当数字运算结果超过了JavaScript所能表示的数字上限(溢出),结果为一个特殊的无穷大(infinity)值,在JavaScript中以Infinity表示。同样地,当负数的值超过了JavaScript所能表示的负数范围,结果为负无穷大,在JavaScript中以-Infinity表示。
https://www.runoob.com/js/js-obj-number.html
1.onerror事件
这篇博客涵盖了JavaScript的基础知识,包括变量赋值、数据类型、对象创建、作用域和变量提升。深入讨论了比较运算符、异常处理、正则表达式、函数调用与作用域以及异步处理(Promise)。还涉及了错误处理、DOM操作、函数自调用以及原型链继承等内容。同时,提到了JavaScript数字处理的特性和误差,以及如何利用onerror事件进行错误捕获。

被折叠的 条评论
为什么被折叠?



