JS数据类型和变量
一、定义变量的方式 1、隐式定义: < script type = "text/javascript" > a = "Hello JavaScript" ; alert ( a ) ; < / script > 2、显式定义: < script type = "text/javascript" > var a ; a = "true" ; alert ( a ) ; < / script > 二、类型转换 1、对于减号运算符,因为字符串不支持减法运算,所以系统自动将字符串转成数值。 2、对于加号运算符,系统直接将数值转为字符串,就成了两个字符串进行连接运算。 例: < ! DOCTYPE html > < html lang = "en" > < head > < meta charset = "UTF-8" > < meta name = "viewport" content = "width=device-width, initial-scale=1.0" > < meta http - equiv = "X-UA-Compatible" content = "ie=edge" > < title > Document < / title > < / head > < body > < script type = "text/javascript" > var a = "3