1.常见的输出语句

(1)alert(); 弹出警告窗;
(2)document.write();在文档中写入;
(3)console.log();在控制台输出日志;
例如:
alert(‘hello world’);
document.write(‘hello world’);
console.log(‘hello world’);
web前端开发JS基础知识

2.变量命名规则

(1)必须以字母,下划线或者$开头。
(2)可以由字母,下划线 $或数字组成。
(3)不能使用关键字和保留字。
(4)区分大小写。

3.基本数据类型(原始数据类型)

(1)数值类型:number 例:1,2,1.1,-1…等
(2)字符串类型:string
(3)布尔类型:boolean; true(真)false(假);变量值为0就是false,否则为true,且boolean只有这两个值。
(4)undefined:未定义,也就是变量为初始化。
(5)null:空

4.数据类型检测

typeof表达式运算结果为string类型;
变量的类型取决于存储的数据(类型可变);

相关文章:

  • 2021-11-04
  • 2021-12-29
  • 2021-08-08
  • 2021-08-08
  • 2021-11-12
  • 2021-12-21
  • 2021-12-05
  • 2021-11-24
猜你喜欢
  • 2021-10-17
  • 2021-11-22
  • 2021-08-08
  • 2022-01-13
  • 2021-08-08
  • 2021-11-12
  • 2021-12-10
相关资源
相似解决方案