javascript是什么

原文p2pu:http://new.p2pu.org/en/groups/javascript-101/content/week1/

js是能被浏览器理解的代码。

你可以在浏览器地址栏输入

javascript: alert("Hi, I'm a program.");

然后回车,祝贺你,已经运行了一个js程序。

Now hop over to http://goo.gl/wYwXx and paste

alert("Hi, I'm a program.");

into the left hand window and press preview (the emulation runs the code) and you see the same result as previously.

Now make a copy of the html in the right window and save it to a html file on your own computer, use it as a template for testing, assignments and so on.

So how and where in your html template do you put the javascript? Like other things that go in Html pages Javascript has its own set of opening/closing tags and the code goes between them like this:

<script type="text/javascript"> alert("Hi, I'm a program."); </script>
and then very often (not always) the above is inserted between the head tags on the page. Try it now, paste the above anywhere between the head tags in a copy of your template and open it in your browser.

However the best way is to put the javascript code in its own file so make up a file with extension .js and put the code in there and store the file in the same folder as your template, then in your template file make a call to that file like this:

<script type="text/javascript" src="yourfile.js"> </script>
Now if you open the file in the browser, the code gets executed just as previously. This is the same way that third party libraries such as JQuery get called. ( Don't worry right now if you don't know what a library or JQuery is ). Notice that this is also what is happening in JS Bin, the code is being executed as if it were in a separate file.

The program consists of a statement which is a call to the function that is the value of the property named alert of the global object. If this doesn't make too much sense to you right now, all will become clear later on.

Next listen to Douglas Crockford's video at http://yui.zenfs.com/theater/crockford-tjpl-1.m4v

Now do the javascript presentation and assignment at http://bit.ly/eANeSx (those of you feeling a bit rusty on html or css should have a look at those presentations as well).

Start working your way through the List of Examples Online for sections 1.1 thru 2.5 . (Alternate link http://umust.be/js101/index.html). You should have some familiarity with all these lessons as soon as you possibly can.
[[--- Javascript, managed by the Mozilla Foundation, as of 27 July 2010 in version 1.8.5, is an implementation (dialect) of ECMA-262 Edition 5 (aka ECMAScript5) of 3 December 2009; support for this version exists in FF4, IE9, Safari5 and Chrome10. Older browsers would have support for Edition 3.

Although not strictly correct, most people when using the word "javascript" mean any implementation in browsers, not only that of Mozilla Foundation; in fact, Javascript is now an Oracle trademark.

http://kangax.github.com/es5-compat-table/
http://kangax.github.com/es5-compat-table/non-standard/---]]

Then put up a page on your site with answers to the following and any other thoughts you might have had up to now:-


When parsing a String into a number using the parseInt() method, we are advised to always provide the radix. Why is this?
Why do we lose precision when performing operations with decimal numbers in Javascript? Can you think of a few implications of why this would be a problem?
Do you understand why the next operation produces the given result 115 * 4 - 4 + 88 / 2 = 500?
What is a type, and why do you think types are useful in writing programs?
What does typeof(4.5); do, and why does typeof(typeof(4.5)); return "string" ?
"+" in Javascript is overloaded, what does this mean?
You might be interested in how your peers commented on this and other matters in the previous incarnation of this course, here http://bit.ly/hic9F4.



http://goo.gl/saHWg Web development - twenty six concepts or technologies.

http://goo.gl/xVu6Y Beginner best practices.

http://goo.gl/lztxB Javascript Primitive Types

http://goo.gl/t6teZ Javascript Composite Types

http://goo.gl/DTsJc Another Intro

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
©️2022 CSDN 皮肤主题:大白 设计师:CSDN官方博客 返回首页
评论

打赏作者

freeagle

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值