0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

JavaScript,13,Number,String,初心者向け

Posted at

型(type)とは?JavaScriptにおける型の紹介と扱い方、型変換の方法について紹介!

Number(数値)型
String(文字列)型

1000と打ち込んでも数値の1000と文字列の1000は別物

文字と数値を足すと1000 + 1000 は

10001000

になる

文字列を数値にするには

textContentから取ってきたものは文字列になる
カーソルを合わせるとStringって出てくる

inputが要素だとして

何型か調べるには
Console.log(typeof input)

数値に変換するには
input = Number(inpput)
( )の中に変換したいものを入れると変わる

0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?