1、字符串类型:
const greeting = 'Hello, world!';
const name = 'John';
const message = Hi, ${name}!
;
console.log(greeting);
console.log(name);
console.log(message);
2 、数字类型:
const age = 28;
const price = 9.99;
const quantity = 10;
const total = price * quantity;
console.log(age);
console.log(price);
console.log(quantity);
console.log(total);
3、布尔类型:
const isStudent = true;
const hasJob = false;
console.log(isStudent);
console.log(hasJob);
4、null类型:
const result = null;
console.log(result);
5、undefined类型:
let username;
const password = undefined;
console.log(username);
console.log(password);
6、对象类型:
const person = {
name: 'John',
age: 28,
isStudent: true
};
console.log(person.name);
console.log(person.age);
console.log(person.isStudent);
//代码效果参考:http://www.zidongmutanji.com/zsjx/545363.html
7、数组类型:
const fruits = ['apple', 'banana', 'orange'];
console.log(fruits[0]);
console.log(fruits[1]);
console.log(fruits[2]);