diff --git a/sources/tech/20210722 Write your first JavaScript code.md b/sources/tech/20210722 Write your first JavaScript code.md index d02ca214cd..9e1af727df 100644 --- a/sources/tech/20210722 Write your first JavaScript code.md +++ b/sources/tech/20210722 Write your first JavaScript code.md @@ -1,18 +1,19 @@ -[#]: subject: (Write your first JavaScript code) -[#]: via: (https://opensource.com/article/21/7/javascript-cheat-sheet) -[#]: author: (Seth Kenlon https://opensource.com/users/seth) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: subject: "Write your first JavaScript code" +[#]: via: "https://opensource.com/article/21/7/javascript-cheat-sheet" +[#]: author: "Seth Kenlon https://opensource.com/users/seth" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " Write your first JavaScript code ====== -JavaScript was created for the web, but it can do so much more. Learn -the basics, then download our cheat sheet so you always have the details -at hand. -![Code with javascript on white background][1] +JavaScript was created for the web, but it can do so much more. Learn the basics, then download our cheat sheet so you always have the details at hand. + +![open source programming][1] + +Image by: Opensource.com JavaScript is a programming language full of pleasant surprises. Many people first encounter JavaScript as a language for the web. There's a JavaScript engine in all the major browsers, there are popular frameworks such as JQuery, Cash, and Bootstrap to help make web design easier, and there are even programming environments written in JavaScript. It seems to be everywhere on the internet, but it turns out that it's also a useful language for projects like [Electron][2], an open source toolkit for building cross-platform desktop apps with JavaScript. @@ -26,50 +27,44 @@ As you progress with JavaScript, you may find yourself wanting advanced JavaScri To write your first JavaScript code, open your favorite text editor, such as [Notepad++][3], [Atom][4], or [VSCode][5]. Because it was developed for the web, JavaScript works well with HTML, so first, just try some basic HTML: - ``` -<[html][6]> - <[head][7]> - <[title][8]>JS</[title][8]> - </[head][7]> - <[body][9]> - <[p][10] id="example">Nothing here.</[p][10]> - </[body][9]> -</[html][6]> + +
+Nothing here.
+ + ``` Save the file, and then open it in a web browser. -![HTML displayed in browser][11] - -(Seth Kenlon, [CC BY-SA 4.0][12]) - -To add JavaScript to this simple HTML page, you can either create a JavaScript file and refer to it in the page's `head` or just embed your JavaScript code in the HTML using the ` + +