javascript入门笔记(1)——变量和计算

introduction


前言

这几章笔记是看了翁凯老师的网上教程做的,这份教程很基础,没有学过编程的同学也可以轻松学习,并且会根据例子讲很多平常容易弄错的细节语法,而且老师声音很好,像是学过播音,让人容易听得进去课。
课程链接: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:

  1. Writing into an alert box, using window.alert().
  2. Writing into the HTML output using document.write(). //wipe all contents after click
  3. Writing into an HTML element, using innerHTML.
  4. 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>
  1. javascript can use “+” to append character strings.
  2. 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;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值