mosh ES

Operator

arithmetic operators: baiscly like python but include ++ and -- like the ones in c++. "+=" shortcut like this is also applicable.

comparision operator:

>,>=,.....

use === as strict equality operator.会同时比较类型和值 ”==“只比较值(会把右边的转换成左边的type如console.log(true=1))

ternary operator

python usually do below:

logical operator:

and:&&

or:||

not:!

bitwise or : |

Arrays and function:

array adding element

Finding elements: (primitive types) i.e. === , if it's reference type, reference will be checked, so we can't use this method.

indexOf: if not exist, return -1, the 2 of (1,2) means starting position

reference type:

we use array.find() method array.findIndex() to get the index

function is running through every elements of the array1 untill find the matched one.

Object:

 as shown above, javascript may return a trusy value instead of boolean!

possible usage:

if customer choose a color , it will use the one chosen by customer otherwise will use the default one. 

 defining a object example:

factory functions:

跟constructor差不多

radius 等价于 radius: radius

draw: function(){...}=draw(){} 

constructor:

new operator首先创造一个空对象,然后用这个this指针指向这个空对象,add features dynamicly and then return it . 

adding and removing properties of the object:

although it is const circle, it means circle can't be assigned again, but we can still modify its features. 

reference types and primitive types: 

函数也是对象:

如下图例子, function circle(radius)其实是调用了new Function这个constructor 

for..of is only applicable to thingies that is iterable, such as arrays and maps

we may use Object.keys(object) or Object.entries(object) which returns a array of strings

clone object using Object.assign() or spread operator

garbage collector system

unlike C/c++ in which we need to do garbage collection manual. Javascript has complex algorithm running under the scene to recycle unused garbage

Built-in object

Math

String:

it is a primitive , but javascript engine will transform it to an object if we call method 

template literals:

To format strings in a more elegant way 

Date:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值