A doubt in some promise polyfill

clipboard.png

as shown in the figure above, what is not clear is: why then uses dot syntax, while catch and finally use [] syntax because catch and finally are keywords in js? I don"t know what I don"t know about this.

this is the github address of this polyfill, on lines
https://github.com/taylorhake.


should be the reason for the keyword


js keyword and cannot be used as variable, function name, procedure, and object name.
originally, he is also right, but you don't know what kind of mistake will happen when you use it with other things.
for example, when some tools are compressed. It's over.
this makes it much safer.


I don't have much knowledge, but the author just mixes it at will.
you see that the implementation of this promise is Promise.prototype.finally
https://github.com/then/promi.


agree with upstairs.

in fact, there is no problem with this way of writing at 99%.

another 1% chance that the compiler will compile your code into something else will be a problem. I yy an example:

// 


Promise.prototype = function catch(onReject) {};
Menu