javascript入门笔记(1)——变量和计算
16lz
2021-01-22
introduction
-
- introduction
- 前言
- JavaScript Display Possibilities
- variable
- arithmetic
前言
这几章笔记是看了翁凯老师的网上教程做的,这份教程很基础,没有学过编程的同学也可以轻松学习,并且会根据例子讲很多平常容易弄错的细节语法,而且老师声音很好,像是学过播音,让人容易听得进去课。
课程链接:http://study.163.com/course/courseMain.htm?courseId=195001
记笔记的时候在国外,电脑上装不了中文输入法,只好用英文了,markdown写的,编辑器是stackedit,很好用的一款网页编辑器,推荐。
<body onLoad="alert('hi')">
<script>
document.write('hey');
</script>
</body>
document is an object, write() is an action.
onload is an attribute of body.
notice:
1. two layers of quotation is not valid.
change one to single quotation.
2. semicolon is necessary.
JavaScript Display Possibilities
JavaScript can “display” data in different ways:
- Writing into an alert box, using window.alert().
- Writing into the HTML output using document.write(). //wipe all contents after click
- Writing into an HTML element, using innerHTML.
- Writing into the browser console, using console.log().
variable
<body>
<script>
var a = "hello"; //assignment, not equality
document.write(a);
</script>
</body>
the name of the variable can only consist of number, character, and underline.
ps: number can’t be in the first place.
arithmetic
<body>
<script>
var a = "hello";
var b ="15";
document.write(a+b);//result is hello15
</script>
</body>
- javascript can use “+” to append character strings.
- double ” ” writes as single ” ” cuz html
<body>
<script>
var a = "hello";
document.write(a >= "gello");//result is true
</script>
</body>
character string can also be compared, usually the value is based on there ASCII code.
order:
number< uppercase character< lower case character;
更多相关文章
- 设计html编辑器预览功能背后的理论
- IronPython编辑器 —— FantasyPython雏形的雏形
- 支持c和python之间的跨语言(c)标记的代码编辑器
- VIM 编辑器使用基础介绍
- 个人网站对xss跨站脚本攻击(重点是富文本编辑器情况)和sql注入攻击
- Mix-Editor图文编辑器----Android图文编辑器