语言特色JS

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';
}

 https://developer.mozilla.org/zh-CN/docs/Learn/JavaScript/Objects/Inheritance#%E5%AE%9A%E4%B9%89_teacher_%E6%9E%84%E9%80%A0%E5%99%A8%E5%87%BD%E6%95%B0

1.JS数字不分为整数类型和浮点型类型,所有的数字都是由 浮点型类型,浮点数运算不一定精准

1.当数字运算结果超过了JavaScript所能表示的数字上限(溢出),结果为一个特殊的无穷大(infinity)值,在JavaScript中以Infinity表示。同样地,当负数的值超过了JavaScript所能表示的负数范围,结果为负无穷大,在JavaScript中以-Infinity表示。

https://www.runoob.com/js/js-obj-number.html

1.onerror事件

https://www.runoob.com/try/try.php?filename=tryjs_onerror

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值