LoginSignup
1
0

More than 3 years have passed since last update.

論理演算子はboolean以外も返す const = AA || BB みたいなの

Last updated at Posted at 2020-09-07

JavaScriptの「&&」「||」について盛大に勘違いをしていた件 - Qiita

const _perview = Number($body.getAttribute('data-perview')) || 'auto';

えっなにこれ、って思ってた。

Number($body.getAttribute('data-perview'))trueであればNumber($body.getAttribute('data-perview'))を返す。そうでなければ'auto'を返す。

そういう使い方出来るのね…if文的な時でしか使えないと思ってたよ本当に…

1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0