ecmascript-2020

How is the nullish coalescing operator (??) different from the logical OR operator (||) in ECMAScript?

╄→尐↘猪︶ㄣ 提交于 2021-01-27 18:48:10
问题 ES2020 introduced the nullish coalescing operator ( ?? ) which returns the right operand if the left operand is null or undefined. This functionality is similar to the logical OR operator ( || ) . For example, the below expressions return the same results. const a = undefined const b = "B" const orOperator = a || b const nullishOperator = a ?? b console.log({ orOperator, nullishOperator }) result: { orOperator:"B", nullishOperator:"B" } So how is the nullish operator different and what is its

What exactly the “LeftFirst” Boolean Flag is in “Abstract Relational Comparison Algorithm” in ECMAScript?

孤者浪人 提交于 2020-05-14 08:59:06
问题 Can someone explain what exactly the LeftFirst Boolean Flag is in Abstract Relational Comparison Algorithm in ECMAScript ? I know that there is only one operator < handling all other relational operators like > , >= , <= as mentioned in the ECMAScript specification in Abstract Relational Comparison using the LeftFirst Boolean Flag for, and example: when we write and run an operation like 10 > 5 the LeftFirst Boolean Flag becomes false , and the left operand 10 is moved to the right side where