Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ What are Data-types? | Data Types and Variables
/
Introduction to JavaScript (staging)
セクション 3.  2
single

single

bookWhat are Data-types?

メニューを表示するにはスワイプしてください

What are Data-types?

The values which we assign to the variables are of a specific type which is called the data type of that specific variable. We can assign numbers, string, boolean, null, undefined, array, object, functions, and symbols to variables.

Introduction to different Data-types

Following is a brief introduction to the commonly used data types in JavaScript. We will go through these in detail in the upcoming chapters, but for now, let’s just get a basic understanding of all these.

  • Number

Numbers are always floating-point numbers so both the integers as well as floating-point numbers are simply numbers in JavaScript.

12
let totalCoins=100; console.log(totalCoins)
copy
  • BigInt: BigInt is used to represent numbers of arbitrary lengths. A BigInt number can be generated by appending n at the end of a number.
123
// the "n" at the end means it's a BigInt const bigInt = 12345678901234567890123n; console.log(bigInt);
copy

Strings:
We use quotes to represent the strings. They are commonly used to deal with text.

12
let comment="good"; console.log(comment);
copy
  • Boolean (logical type): In this type, we have only two values: true and false. We use true for “Yes”, and false is used for “No”. For instance, if we want to store the value of "It's raining" we will set the value to true and if it is not raining then we will set the value false.
12
let isRaining = true; console.log(isRaining);
copy
  • null: The null is a special value that represents “nothing”, “empty”, or “value unknown”.
12
let selectedColor = null; console.log(selectedColor)
copy
  • Undefined: In JavaScript, a default value of undefined is assigned to the variable if we do not assign a value to it.
12
let age; console.log(age);
copy

The typeof Operator:

The typeof operator is used to get the type of the value or variable. It’s useful to quickly check the types of values that are assigned to the variable. To check the type we use the typeof keyword and pass the variable inside parentheses.

12
let drink="soda"; console.log('typeof("drink"):', typeof(drink));
copy
タスク

スワイプしてコーディングを開始

Check the type of the following variable and display it on the console.

解答

Switch to desktop実践的な練習のためにデスクトップに切り替える下記のオプションのいずれかを利用して、現在の場所から続行する
すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 3.  2
single

single

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

some-alt