JavaScript Learning record Day1

Source: Internet
Author: User

JavaScript Learning record Day1


学习javascript



    • JavaScript Learning record Day1

      • 1. Quick Start

      • 2. Programming tools

      • 3. Syntax

      • 4. Notes

      • 5. Case


What is Javascritps?
JavaScript is a literal-translation scripting language, which is a dynamic type, a weak type, a prototype-based language, and a built-in support type. Its interpreter, known as the JavaScript engine, is widely used as a scripting language for the client, and is used in HTML (an application under the standard Universal Markup Language) to add dynamic functionality to an HTML Web page.

In the Web world, only JavaScript can drive web pages across platforms and across browsers, interacting with users.

the process of writing JS
Layout: Html+css
Properties: Determining which properties to modify
Event: Determine what the user is doing (product design)
Write JS: In the event, use JS to modify the style of the page elements

1. Quick Start

JavaScript code can be embedded directly anywhere on the page, but usually we put JavaScript code in:

<! DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My first JS</title>
<script>
function myfirstscript() {
Alert ("Hello word!");
}
Myfirstscript ();
</script>

</head>
<body>

</body>
</html>

The <script>...</script> included code is the JavaScript code that will be executed directly by the browser.

The second way is to put the JavaScript code in a separate. js file, and then in the HTML by introducing this file:

<html>
<head>
<script src="/static/js/abc.js"></script>
</head>
<body>
...
</body>
</html>

This way, the/static/js/abc.js will be executed by the browser.
Putting JavaScript code in a separate. js file is more conducive to maintaining code, and multiple pages can each reference the same. js file.
Multiple. js files can be introduced in the same page, and they can be written several times in the page <script> js代码... </script> , followed sequentially by the browser.

2. Programming tools

I use Webstorm, the tool is very useful, but it is a fee software, you can use its open source license.
https://www.jetbrains.com/webstorm/

3. Syntax

javascript syntax is similar to the Java language, with each statement ; End, statement block with {.} . However, JavaScript does not force the requirement at the end of each statement to add , the engine responsible for executing JavaScript code in the browser automatically complements the .

> Note: Having the JavaScript engine automatically add semicolons in some cases alters the semantics of the program, resulting in inconsistent running results and expectations. In order to develop good habits, we do not omit , all statements are added .

if  (2  > 1 ) {
   x = 1 ;
   y = 2 ;
   z = 3 ;
}

Note that {...} the statement inside the curly braces has indentation, usually 4 spaces. Indenting is not required for JavaScript syntax, but indentation helps us understand the hierarchy of code, so we follow indentation rules when writing code. Many text editors have the ability to "auto indent" to help organize your code.

4. Notes

The // characters that begin with the end of the line are treated as line comments, and the comments are for developers to see that the JavaScript engine automatically ignores:

// 这是一行注释
alert(‘hello‘// 这也是注释

//另一种块注释是用/*...*/把多行字符包裹起来,把一大“块”视为一个注释:
/* 从这里开始是块注释
仍然是注释
仍然是注释
注释结束 */
5. Case

Note that JavaScript is strictly case sensitive, and if the case is mistaken, the program will either error or run abnormally.

Learning Reference Tutorial: http://www.liaoxuefeng.com


This article is from the "YGQYGQ2" blog, make sure to keep this source http://ygqygq2.blog.51cto.com/1009869/1917258

JavaScript Learning record Day1

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.