当前位置:网站首页>Simple test JS code
Simple test JS code
2022-07-24 17:53:00 【Zero one_】
Copyright notice : Reprint please indicate the source https://blog.csdn.net/nk1212582/article/details/81321202
background
because JS The program cannot be like C++、Python Programs run separately , It is not conducive to testing the function of a piece of code
Purpose
A short test JS Code
step
(1) Create a new one test.html file
(2) stay test.html Write the following in the document
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>test</title>
<script type="text/javascript">
</script>
</head>
<body>
</body>
</html>(3) stay test.html Write what needs to be tested JS Code , as follows
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>test</title>
<script type="text/javascript">
function Student(name, age){
this.name = name;
this.age = age;
this.description = function(){
return this.name + " The age of :" + this.age;
}
}
var p4 = new Student("Tony", 28);
var p5 = new Student("Tom", 40);
console.log(p4.description()) // Output is :Tony The age of :28
console.log(p5.description()) // Output is :Tom The age of :40
</script>
</head>
<body>
</body>
</html>
(4) Open it in a browser test.html, Press F12, see console.log() The contents of the printout
边栏推荐
- C语言中的字符与字符串库函数的使用以及模拟实现
- Blackmagic Fusion Studio 18
- Practical application cases of digital Twins - Smart Park
- 0612~quartz定时器框架
- 《STL源码剖析》应该怎样读?
- Wrote a few small pieces of code, broke the system, and was blasted by the boss
- Gan Development Series II (pggan, Singan)
- 0621~ES&Lucene
- 获取同程(艺龙)酒店数据
- 0616 end of Project II ~ ~ general summary
猜你喜欢

NPM install reported -4058 error

In the morning, Tencent took out 38K, which let me see the ceiling of the foundation

Colleges and universities have introduced 23 Philippine doctors with heavy funds, and the relevant departments have launched an investigation!

0625~<config>-<bus>

Practical application cases of digital Twins - Smart Park

Codeforces Round #794 (Div. 2)(A.B.C)

List of stringutils and string methods

Definition and storage of adjacency table and adjacency storage of directed graph and undirected graph

C语言自定义类型讲解 — 联合体

ROC and AUC details of the recommended system
随机推荐
DF2NET三维模型部署
ROC and AUC details of the recommended system
In the morning, Tencent took out 38K, which let me see the ceiling of the foundation
Are the top ten securities companies safe and risky to open accounts?
0611~ self study class
Use yarn
《STL源码剖析》应该怎样读?
0623~ holiday self study
20 -- validate palindrome string
0625~<config>-<bus>
Is header file required? Follow the compilation process~~~
二维卷积——torch.nn.conv2d的使用
0615 ~ realize RBAC permission management with user-defined annotations
Getaverse,走向Web3的远方桥梁
Hcip fourth day notes
干货|值得收藏的三款子域名收集工具
[network security] analysis vulnerability of website Middleware
Today, I met a 38K from Tencent, which let me see the ceiling of the foundation
C语言自定义类型讲解 — 结构体
0614~放假自习