- Programming the BeagleBone
- Yogesh Chavan
- 338字
- 2021-07-23 14:36:46
Hello World program
Let's do a quick and dirty Hello World
JavaScript program. In this program, we are just printing Hello World
in the console view provided by Cloud9:
- Go to the File menu. Click on the New File button. You will see a new code editor tab opened with title
Untitled1
. - Write the following code in the code editor view:
// My first hello world program. console.log("Hello World");
Tip
Downloading the example code
You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
- Go to the File menu again and save as
hello.js
. Now, you should see the tab title is changed fromUntitled1
tohello.js
. Now Cloud9 knows this is JavaScript program. It will highlight the program with different colors. - Click on the run button at the top of screen. You will see the Debugger toolbar from right side is expanded to the Debug pane. Click on the Resume button on expanded pane or press the F8 key. You should see the
Hello World
text in the output view at the bottom.
Explanation
In this tiny code, the first line is the comment. JavaScript supports C and C++ style commenting. So the pattern /* ... */
is used in multi-line commenting and the pattern//
is used for single line commenting. The second line is calling the log()
method on the object console
. We have given the string Hello World
as a parameter to the log()
method. A semicolon ;
denotes a terminated statement. Here, the console
object provides access to the browser's debugging console. console.log()
is a method to print string. It prints Hello World
in the console.
As we are using a built-in JavaScript object, we have not loaded a JavaScript module/library. You can try more methods provided by the console object. You can get a detailed document about JavaScript at: http://www.w3schools.com/js/ and https://developer.mozilla.org/en-US/docs/Web/JavaScript.
- Boost程序庫完全開發指南:深入C++”準”標準庫(第5版)
- 數據庫系統教程(第2版)
- JavaScript 網頁編程從入門到精通 (清華社"視頻大講堂"大系·網絡開發視頻大講堂)
- Programming ArcGIS 10.1 with Python Cookbook
- Oracle數據庫從入門到運維實戰
- JavaScript前端開發與實例教程(微課視頻版)
- 你必須知道的204個Visual C++開發問題
- HTML5+CSS3網站設計教程
- C語言課程設計
- QGIS Python Programming Cookbook(Second Edition)
- MINECRAFT編程:使用Python語言玩轉我的世界
- OpenCV with Python Blueprints
- 玩轉.NET Micro Framework移植:基于STM32F10x處理器
- 交互設計師成長手冊:從零開始學交互
- 實戰Python網絡爬蟲