javascript编程题_学习JavaScript:JavaScript编程开发环境

本文全面介绍了学习JavaScript的多种环境,包括Web浏览器、在线解释器和桌面解释器,如Node和Mozilla Spidermonkey shell,帮助初学者理解如何选择合适的编程环境。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

javascript编程题

One of the nice things about learning JavaScript these days is that there is a plethora of choices for writing and running JavaScript code. In this article, I’m going to describe a few of these environments and show you the environment I’ll be using in this series of articles.

这些天来学习JavaScript的一件好事是,编写和运行JavaScript代码有很多选择。 在本文中,我将描述其中的一些环境,并向您展示在本系列文章中将使用的环境。

环境1 — Web浏览器 (Environment 1 — The Web Browser)

The easiest way to run JavaScript is to simply use your web browser. You can either create an HTML page and put your JavaScript code inside a <script> tag, or you can use the browser’s developer tools to run your programs.

运行JavaScript的最简单方法是仅使用Web浏览器。 您可以创建HTML页面并将JavaScript代码放在<script>标记中,也可以使用浏览器的开发人员工具来运行程序。

If you use HTML, here is a Hello, world! example to show you how your file should look (I’m skipping some HTML best practices to create a minimal system):

如果您使用HTML,那么您好,世界! 向您展示文件外观的示例(我跳过了一些HTML最佳实践来创建一个最小的系统):

<!doctype html>
<html>
<head>
<script>
alert("Hello, world!");
</script>
</head>
<body>
</body>
</html>

Save the file with a .html extension and then use the Open File command in your browser to load the page. “Hello, world!” will appear in a box in the browser.

使用.html扩展名保存文件,然后在浏览器中使用“打开文件”命令加载页面。 “你好,世界!” 将显示在浏览器的框中。

The other way to run JavaScript programs in the browser is to use the browser’s developer tools. For Chrome and Firefox, if you press F12, the web developer console opens and you can input your programs here.

在浏览器中运行JavaScript程序的另一种方法是使用浏览器的开发人员工具。 对于Chrome和Firefox,如果按F12键,则将打开Web开发人员控制台,您可以在此处输入程序。

Look for the command prompt >>. Type your JavaScript commands there and hit Enter to have the browser evaluate your code.

查找命令提示符>> 。 在此处输入您JavaScript命令,然后按Enter键,以使浏览器评估您的代码。

Here is an example:

这是一个例子:

>> console.log("Hello, world!");
Hello, world!
-> undefined

undefined just means that the statement you ran didn’t assign a value to anything.

undefined只是意味着您运行的语句未为任何值分配值。

The Chrome browser’s developer tools work similarly.

Chrome浏览器的开发人员工具的工作原理与此类似。

环境2-在线口译员 (Environment 2 — Online Interpreters)

There are several online interpreters you can use to write JavaScript programs. A simple one to use is https://repl.it. If you go to the web page, you just select JavaScript from a drop-down menu and you are presented with an editor screen to write your JavaScript code, as shown in the screen shot below:

您可以使用多个在线解释器来编写JavaScript程序。 一个简单的使用方法是https://repl.it 。 如果转到网页,只需从下拉菜单中选择JavaScript,然后会看到一个编辑器屏幕来编写JavaScript代码,如以下屏幕截图所示:

Image for post
repl.it
代表

Another basic online JavaScript code editor and interpreter is https://js.do.

另一个基本的在线JavaScript代码编辑器和解释器是https://js.do

There are other, more advanced online editor/interpreters such as CodePen.io and JsFiddle. However, these probably have too many features for the beginning JavaScript programmer and should be used only after you’ve gained some JavaScript programming experience.

还有其他更高级的在线编辑器/解释器,例如CodePen.io和JsFiddle。 但是,对于刚开始JavaScript程序员来说,这些功能可能有太多功能,只有在您有一定JavaScript编程经验之后才应该使用这些功能。

环境3-桌面口译员 (Environment 3 — Desktop Interpreters)

There are two major desktop JavaScript interpreters you can use for learning JavaScript. These interpreters are Node and the Mozilla Spidermonkey shell.

您可以使用两个主要的桌面JavaScript解释器来学习JavaScript。 这些解释器是Node和Mozilla Spidermonkey shell。

If you know much about the JavaScript ecosystem you have at least heard of Node. I won’t go into all the aspects of this JavaScript-based system for web development, but I will mention that when you download Node you get a JavaScript command line interpreter for your desktop.

如果您对JavaScript生态系统了解很多,那么您至少听说过Node。 我不会介绍用于Web开发的基于JavaScript的系统的所有方面,但是我会提到,当您下载Node时,您将获得用于桌面JavaScript命令行解释器。

Go to https://nodejs.org to download Node for your type of computer. After the download and installation, you can open a command line shell by simply typing:

转到https://nodejs.org下载适用于您的计算机类型的Node。 下载和安装后,只需键入以下内容即可打开命令行外壳:

node

node

This will open a command prompt and you can begin entering JavaScript code. Here is a screen shot of the Node shell running on my desktop:

这将打开命令提示符,您可以开始输入JavaScript代码。 这是在我的桌面上运行的Node shell的屏幕截图:

Image for post
node shell
节点外壳

If you are new to JavaScript, don’t worry about all the code you see. You’ll be learning about it all soon enough.

如果您不熟悉JavaScript,请不要担心看到的所有代码。 您很快就会学到这一切。

The other popular JavaScript shell, and the one I will be using in these articles, is the Mozilla Spidermonkey shell. This shell is like Node’s shell but does have some differences I prefer, which I’ll discuss in more detail in individual articles.

Mozilla Spidermonkey外壳是另一个流行JavaScript外壳,也是我将在本文中使用的外壳。 该外壳类似于Node的外壳,但确实有一些我喜欢的区别,我将在每篇文章中对其进行详细讨论。

You can download the Spidermonkey shell here:

您可以在此处下载Spidermonkey shell:

https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/

https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/

Scroll down until you find the binary file for your operating system type.

向下滚动,直到找到适合您操作系统类型的二进制文件。

Download the file and copy it to a convenient spot on your computer. To run the shell, type js at the command prompt. Here is a screen shot of my shell:

下载文件并将其复制到计算机上的方便位置。 要运行外壳程序,请在命令提示符下键入js 。 这是我的外壳的屏幕截图:

Image for post
Spidermonkey shell
蜘蛛猴壳

您已经准备好开始编程 (You’re Ready to Start Programming)

Now that you’ve seen the different environments you can use for JavaScript programming, you’re ready to get started. My first article will discuss the different types of data used in JavaScript programs and how to create variables and store data in them.

既然您已经了解了可用于JavaScript编程的不同环境,那么就可以开始了。 我的第一篇文章将讨论JavaScript程序中使用的不同类型的数据,以及如何创建变量并在其中存储数据。

Thanks for reading and please email me with comments and suggestions.

感谢您的阅读,请给我发电子邮件以提供评论和建议。

翻译自: https://levelup.gitconnected.com/learning-javascript-development-environments-for-javascript-programming-a1fe3751d915

javascript编程题

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值