JavaScript basic syntax learning tutorial_javascript skills
Basic concepts of Javascript
i. Javascript language is a scripting language widely used in web pages.
ii. Characteristics of Javascript language:
1. Developed by Netscape, it is a scripting language that is object- and event-driven and has certain security.
2. Features:
a) Javascript is a scripting language and an interpreted language;
b) Javascript is run by the javascript interpreter in the browser and has nothing to do with the operating environment;
c) In JavaScript, less strict data types are used. The advantage of this is that it is more convenient when defining or using data, but it also brings about the problem of confusion;
d) Javascript is an object-based language, so you can create objects yourself and use the properties and methods in the objects you create to create many functions;
e) The main function of Javascript is to animate the web page, and there is also a certain amount of interaction;
f) Javascript is secure and does not allow users to access the local hard disk or modify or delete documents on the network. This can effectively prevent data loss and malicious modification.
g) Example: HTML file built-in script
<script language="javascript"> Document.write("<font color=blue>Hello,JavaScript!</font>"); </script> HTML文件外接脚本 <script src="1.js"> </script> //1.js Document.write("<font color=blue>JavaScript,Hello!</font>");
JavaScript statement
Commands issued by JavaScript statements to the browser. The purpose of a statement is to tell the browser what to do.
Semicolon ;
Semicolons are used to separate JavaScript statements.
Usually we add a semicolon at the end of each executable statement.
Another use of semicolons is to write multiple statements on one line.
Tip: You may also see cases without semicolons.
In JavaScript, terminating a statement with a semicolon is optional.
JavaScript code
JavaScript code (or just JavaScript) is a sequence of JavaScript statements.
The browser will execute each statement in the order it is written.
JavaScript code block
JavaScript statements are grouped into blocks of code.
block starts with a left curly brace and ends with a right curly brace.
block is to cause a sequence of statements to be executed together.
JavaScript functions are a classic example of combining statements in blocks.
The following example will run a function that operates on two HTML elements:
JavaScript is case sensitive
JavaScript is case-sensitive.
When writing JavaScript statements, please pay attention to whether the case switch key is turned off.
The functions getElementById and getElementbyID are different.
Similarly, the variables myVariable and MyVariable are also different.
JavaScript Comments
JavaScript will not execute comments.
We can add comments to explain JavaScript or improve the readability of the code.
Single-line comments start with //.
JavaScript multi-line comments
Multi-line comments start with /* and end with */.
JavaScript Variables
Like algebra, JavaScript variables can be used to store values (such as x=2) and expressions (such as z=x y).
Variables can have short names (like x and y) or more descriptive names (like age, sum, totalvolume).
•Variables must start with a letter
•Variables can also start with $ and _ symbols (although we don’t recommend this)
•Variable names are case sensitive (y and Y are different variables)
Tip: JavaScript statements and JavaScript variables are case-sensitive.
JavaScript data types
JavaScript variables can also hold other data types, such as text values (name="Bill Gates").
In JavaScript, a text like "Bill Gates" is called a string.
JavaScript variables come in many types, but for now, we’ll just focus on numbers and strings.
When you assign a text value to a variable, you should surround the value with double or single quotes.
Don’t use quotes when the value you assign to a variable is a numeric value. If you surround a numeric value with quotes, the value is treated as text.
JavaScript Timing Events
By using JavaScript, we have the ability to execute code after a set time interval, rather than immediately after the function is called. We call them timing events.
Using timing events in JavaScript is easy, two key methods are:
setTimeout()Execute code at some time in the future
clearTimeout()Cancel setTimeout()
Through the above content, I have introduced you to the basic syntax of JavaScript, and I hope it will be helpful to you in your future work and study.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Detailed explanation of JavaScript string replacement method and FAQ This article will explore two ways to replace string characters in JavaScript: internal JavaScript code and internal HTML for web pages. Replace string inside JavaScript code The most direct way is to use the replace() method: str = str.replace("find","replace"); This method replaces only the first match. To replace all matches, use a regular expression and add the global flag g: str = str.replace(/fi

Leverage jQuery for Effortless Web Page Layouts: 8 Essential Plugins jQuery simplifies web page layout significantly. This article highlights eight powerful jQuery plugins that streamline the process, particularly useful for manual website creation

So here you are, ready to learn all about this thing called AJAX. But, what exactly is it? The term AJAX refers to a loose grouping of technologies that are used to create dynamic, interactive web content. The term AJAX, originally coined by Jesse J

This post compiles helpful cheat sheets, reference guides, quick recipes, and code snippets for Android, Blackberry, and iPhone app development. No developer should be without them! Touch Gesture Reference Guide (PDF) A valuable resource for desig

jQuery is a great JavaScript framework. However, as with any library, sometimes it’s necessary to get under the hood to discover what’s going on. Perhaps it’s because you’re tracing a bug or are just curious about how jQuery achieves a particular UI

10 fun jQuery game plugins to make your website more attractive and enhance user stickiness! While Flash is still the best software for developing casual web games, jQuery can also create surprising effects, and while not comparable to pure action Flash games, in some cases you can also have unexpected fun in your browser. jQuery tic toe game The "Hello world" of game programming now has a jQuery version. Source code jQuery Crazy Word Composition Game This is a fill-in-the-blank game, and it can produce some weird results due to not knowing the context of the word. Source code jQuery mine sweeping game

Article discusses creating, publishing, and maintaining JavaScript libraries, focusing on planning, development, testing, documentation, and promotion strategies.

This tutorial demonstrates how to create a captivating parallax background effect using jQuery. We'll build a header banner with layered images that create a stunning visual depth. The updated plugin works with jQuery 1.6.4 and later. Download the
