JavaScript Trick

こんな コードがあるとして、

const theLength="Hello world".length;


const {theLength:length}="Hello world"

JavaScriptの場合、StringといえどもObjectなので Object Destructuringを使えるわけ。(IE 11 は使えません。)


Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.