Basic syntax of JavaScript learning notes

韦小宝
Release: 2017-11-30 09:43:37
Original
1416 people have browsed it

JavaScriptLearn the basic grammar of notes. For students who are not familiar withJavaScriptand are not familiar with the basic grammar ofJavaScript, you can save it and take a look!

Variousarithmetic operators,comparison operators,logical operators;

if else statement,switch statement;

You can check the reference links at the end of the article.

The following contents are all different parts of JavaScript.

This article first talks about the differences in several details in the above content.

1. Congruence judgment

There is a congruence judgment === in JavaScript comparison operator, which is used to judge whether the value and type are both equal.

2.for/in loop

The for/in loop in JavaScript is a bit like the enhanced for loop in Java, but it is used

Traverse the properties of the object.

var person={fname:"John",lname:"Doe",age:25}; for (x in person) { txt=txt + person[x]; }
Copy after login
Where x is the attribute name, person[x] is the value of the attribute.
3.With statement

With the With statement, when accessing the objectproperties and methodsThere is no need to repeatedly specify the reference object. In the With statement block, all properties and methods that are not recognized by JavaScript are related to the object specified by the statement block.
Function: Create a default object for a program.

Format: with (){ } That is:

With Object { Statements }
Copy after login

Example: When using write( related to Document object ) or writeln() method, the following form is often used:

document.writeln(”Hello!“);
Copy after login

If a large amount of data needs to be displayed, the same document.writeln() statement will be used multiple times. In this case, it can be like the following program , put all the statements with the Document object as the reference object into the With statement block, thereby reducing the number of statements.

   withTest.html     
Copy after login

4. Line break

You can use a backslash to break a line of code:

document.write("Hello \ World!");
Copy after login
But you can’t break the sentence like this:
document.write \("Hello World!");
Copy after login

The above is the content of the basic grammar of JavaScript learning notes. I hope it will be helpful to students. For more information, please search on this site!

Related recommendations:

javascript programming essentials_JS grammar dictionary_basic knowledge

Summarize 10 common methods in js syntax to improve coding efficiency

Manipulate JSON objects in Javascript and add simple implementations of deletion and modification

The above is the detailed content of Basic syntax of JavaScript learning notes. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!