当前位置:网站首页>JS syntax usage
JS syntax usage
2022-08-05 08:21:00 【Eight ~ male】
JS output statement
alert('value') The browser pops up an alert box
console.log('value') browser console printout information
prompt('info') The browser pops up an input box, and the user enters
Variables in JS
1.1 What is a variable
A variable is a fast space allocated by a program in memory to store data.
The use of variables is divided into two parts: 1. Declaration of variables 2. Assignment
declare a variable
var age; //declare a variable named age
var is the js keyword, used to declare variables (meaning variable variables).After you declare a variable with a keyword, the computer automatically allocates space for the variable.
age: is the variable name defined by the programmer, and we allocate space through the variable name.
Variable assignment aeg=18
Output: console.log(age); or alert(age)
Declaring a variable without assignment will report undefined.
Using a variable without declaring or assigning a value will report an error: tel is not defined
js can be used without declaring variables and assigning them directly.
js data type
Data types are divided into simple and complex types
Simple data types (Number, string, Boolean, Undefined,null)
Complex data type (object)
Simple Data Type Description
Simple Data Types , Description , Default
Number Numeric, including integer and floating point 0
Boolean Boolean type true false Equivalent to 1 and 0 false
String
Undefined var a The declared variable is not assigned a value at this time a=undefined undefined
Null var=null declares that the variable a is empty
边栏推荐
- Basic introduction of stack and queue and C language implementation of functions such as creation, destruction, entry and exit, counting the number of elements, viewing elements, etc., as well as stac
- Qt编写自定义控件:文字聚光灯效果之一
- D2--FPGA SPI interface communication2022-08-03
- 剑指Offer面试题解总结1-10
- 高效使用数码相机的诀窍
- MySQL database error The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid)
- Beautifully painted MM set
- P1103 书本整理
- Why is pnpm hitting npm and yarn dimensionality reduction?
- [Structural Internal Power Cultivation] The Mystery of Enumeration and Union (3)
猜你喜欢
unity 头发的渲染
DataFrame在指定位置插入行和列
MySQL database error The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid)
Chapter 12 贝叶斯网络
SVG大鱼吃小鱼动画js特效
DNS 查询原理详解
JVM运行流程,运行时数据区,类加载,垃圾回收,JMM解析
力扣刷题八月第一天
v-if/v-else determines whether to display according to the calculation
pnpm 是凭什么对 npm 和 yarn 降维打击的
随机推荐
egg framework
php向mysql写入数据失败
【无标题】长期招聘硬件工程师-深圳宝安
How to make a puzzle in PS, self-study PS software photoshop2022, PS make a puzzle effect
嵌入式系统:基本定时器
The Coolest Kubernetes Network Solution Cilium Getting Started Tutorial
Ethernet Principle
How to make pictures clear in ps, self-study ps software photoshop2022, simple and fast use ps to make photos clearer and more textured
【结构体内功修炼】枚举和联合的奥秘(三)
Long-term recruitment embedded development-Shenzhen Baoan
版本号命名规则
EA谈单机游戏:仍是产品组合中极其重要的部分
[Structural Internal Power Cultivation] Structural Realization Stages (2)
Adb authorization process analysis
SVG big fish eat small fish animation js special effects
unity 头发的渲染
Random code generation
Beautifully painted MM set
ps怎么拼图,自学ps软件photoshop2022,PS制作拼图效果
Fiddler tool explanation