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]変数の書き方

Posted at

#変数の書き方
javascriptでは変数の前にvarをつけることで、変数を宣言できます。
varはvariable(変数)の略称です。

var hello = "Hello, World";
app.js
var hello = 'Hello World';
alert(hello);
index.html
<html>
  <head>
    <meta charset="utf-8" />
  </head>
  <body>
    <script src="app.js"></script>
  </body>
</html>

また、「Hello, World」は文字列なので、ダブルクオテーションで囲みましたが、
数値を変数に代入する場合は、ダブルクオテーションは不要です。

var int = 5;
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?