LoginSignup
1

More than 5 years have passed since last update.

【JavaScript 】文字列と数値の演算

Posted at

文字列と数値の演算

'use strict';
console.log('10' * 5); // 50
console.log('10' / 5); // 2
console.log('10' % 5); // 0
console.log('10' - 5); // 5

// 足し算は文字列の連結になる
console.log('10' + 5); // 105

// 文字列を10進数の整数に変換
console.log(parseInt('10', 10) + 5); // 15
console.log(parseInt('str', 10) + 5); // NoN

※Google Chrome で確認
※ES8

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