当前位置:网站首页>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
边栏推荐
猜你喜欢

网络安全研究发现,P2E项目遭遇黑客攻击只是时间问题

uniapp时间组件封装年-月-日-时-分-秒

mySQL数据库初始化失败,有谁可以指导一下吗

SQL语句查询字段内重复内容,并按重复次数加序号

unity urp 渲染管线顶点偏移的实现

How to make pictures clear in ps, self-study ps software photoshop2022, simple and fast use ps to make photos clearer and more textured

Redis实现分布式锁-原理-问题详解

spark集群部署(第三弹)

What is a good movie to watch on Qixi Festival?Crawl movie ratings and save to csv file

Fiddler工具讲解
随机推荐
What is the connection and difference between software system testing and acceptance testing? Professional software testing solution recommendation
哪个是你爱情的颜色?
浅谈自动采集程序及入库
【 a daily topic 】 1403. The increasing order of the sequence, boy
星座理想情人
Nn. Unfold and nn. The fold
Pagoda measurement - building small and medium-sized homestay hotel management source code
七夕给自己new一个chatRobot当对象
最 Cool 的 Kubernetes 网络方案 Cilium 入门教程
Luogu: P2574 XOR的艺术 [线段树]
小本创业者的致胜法宝!
在ASP控制数字及字母输入
DPU — 功能特性 — 管理系统的硬件卸载
Adb 授权过程分析
SVG大鱼吃小鱼动画js特效
Spark cluster deployment (third bullet)
SVG星球大战样式Toggle切换开关按钮
Ethernet Principle
彩绘漂亮MM集
What is a good movie to watch on Qixi Festival?Crawl movie ratings and save to csv file