Javascript syntax is as agile as water.
Aside from the damn execution efficiency, maintainability, and readability, the Javascript syntax is as casual as the spoken language.
--------------------- Expression syntax
There are four expressions: Forward, middle, backward, and regular.
Normal JS uses a forward expression (A + B.
If it is a forward order, + a B; a B +; regular, er, regular is not used for evaluation, but for filtering, can it be used for filtering? Retained first.
If the + symbol is treated as the sum () function,
A + B is sum (A, B ). This is also a forward expression.
That is to say, a function call is a forward expression.
Advantages of the forward expression: sum (1, 2, 3, 4, 5 .....), if you change to the central Order 1 + 2 + 3 + 4 + 5 ...... you need to knock N +.
Can a post-order expression be written as (1, 2, 3, 4, 5). sum ()? It is still possible to change it to [1, 2, 3, 4, 5]. sum. I implemented [1, 2, 3, 4, 5]. WSC (SUM ).
What are the advantages of backward expressions? Assume [1, 2, 3, 4, 5]. WSC (sum (2), [3, 4, 5, 6, 7] is returned. That is, process the elements in the array.
Add a number, [1, 2, 3, 4, 5, 6]. WSC (SUM) or [1, 2, 3, 4, 5]. WSC (sum, 6 ). Does the second method return to the middle-order expression?
For the Middle Order (1 + 2 + 3) * 2, the front order multiply (sum (, 3), 2), and the back order is [, 3]. WSC (SUM ). WSC (multiply, 2)
--------------------- Function call syntax
Normally, func (arg1, arg2 ....)
Can I change the parameter and function positions? Yes.
For example, sum (1, 2) is replaced by 1.sum( 2), and WSC intermediate interface is referenced, [1]. WSC (sum, 2), although the return value is [3], it is easy to convert to 3.
No, this is similar to the back-order expression, because this is the back-order expression.
For [1]. WSC (sum, 2) extracts 1 SUM 2, which is a medium-order expression; extract 1 (sum, 2), 1 as a function, sum and 2 as parameters and this is a pre-order expression.
--------------------- Branch syntax
The normal JS is if (condition) {}. If we regard if as a function, condition as a parameter, and {} as a parameter, we can rewrite it into a forward expression if (condition, {}).
Condition1? Statement1: statment2 is equivalent to else (if (condition1, statement1), stament2) condition1? Statement1: condition2? Statement2: statement3 is equivalent to [condition1, statement1]. WSC (IF). WSC (else_if, [condition2, statment2]). WSC (else, statment3)
If condition1 is true, statement1 is returned; otherwise, null is returned. Then else_if (null, [condition2, statment2]
) Function execution. If it is still null, run else (null, statement3)