Basics
Javascript: 1. Data types and values
javascript: allows the use of 3 basic types of data----numbers, Strings and Boolean values. In addition, it also supports two small data types, null (empty) and undefined (undefined).
Javascript: It also supports the data type-object (object). There are two types of objects in JavaScript, one An object represents an unordered collection of named values, and the other represents an ordered collection of numbered values. In fact, an ordered collection is an array (Array).
javascript: It also defines another special object - function, and some special objects defined by javascript (the same concept as the C# encapsulated class, just use it directly)
<script> <BR>Integer direct quantity: 3 or 10000, to put it bluntly, it is a number <BR>Floating point literals: 3.14, 2345.567, etc., which are the ones with a decimal point. <BR>String literals: "3.14", "demo", etc., the so-called strings are Unicode enclosed in single or double quotes. character sequence. <BR>Convert the number to a string: 1, var s = 100; s ="What you name"; The number will be <BR> converted into a string first <BR>2, var s = 100 ""; add one Empty string <BR> 3. To convert the number into a string more clearly, you can use the String() function or <BR> or use the toString function. <BR>Convert a string into a number: var product = "2" * "2"; In fact, when a string is used in a numeric environment <BR> it will automatically be converted into a number, or it can be subtracted by 0 The same effect can be achieved, or you can use the <BR>Number() function <BR>Boolean value: <BR>What I want to share with you here is conversion: it will be used more in the future. 1. When a Boolean value is used in a numeric environment, true is converted to the number 1, and false is converted to the number 0. In a string environment, true is converted to the string true, and false is converted to the string false <BR>Function: <BR>A function is an executable JavaScript code segment. Let me talk about it here: As a data type, functions can also be assigned to the properties of objects like other types. When the assignment is successful, the properties are often regarded as references to which methods. Commonly used later. <BR>Function direct quantity: var square = function(x){return x*x};//It will be used frequently later and must be understood or remembered<BR></script>
Javascript: 2. Object
1. Object
< ;script>
var o = new Object();//Attention everyone, javascript is case sensitive!
var now = new Date()
var regex = new RegExp("^ ?d{1}d{3}$")//Direct quantity of regular expression
object:
var point = {x:12,y:34};
var point2 = {"super":{day:sunday,day1:monday}}//The properties of the object refer to another object.
Conversion of objects:
When a non-empty object is used in a Boolean environment: it is converted to true. When used in a string environment, JavaScript will call the toString() method of the object and use this function The returned value, when used in a numeric environment: JavaScript will call the valueOf() method of the object. If a basic type is returned, this value will be used. Most of the time, the object itself is returned. In this case The JavaScript callback calls the toString() method to convert the object into a string, and then attempts to convert it into a number. I hope everyone will understand the concepts above and use them in the future.
2. Array
<script> <BR>var array = new Array(); <BR>var arr = new Array(1.2,"Javascript",{x:12,y:23})// <BR>Array literal with parameters: <BR>var a = [1.2,"Javascript",{x:12,y:23}]//The array is numbered [] and the object is numbered {}, which is easy to remember ! <BR></script>
3. Null (empty)
The JavaScript keyword Null is a special value, which means no value. Null is often regarded as a special value of the object type, which means a value without an object. When a variable The value of
is null, then it means that its value is not valid (Array, Object, number, string, Boolean value), details: null is converted to false in a Boolean environment; in a number
environment Convert to 0.
4. Undefined (undefined)
When using an undeclared variable, or using a declared variable but without assigning a value, or using an object property that does not exist, The returned
is the undefined value. In the future (namespaces and modules are still used a lot, everyone needs to understand), details: underfined will be converted to false in the Boolean environment, and it will be converted to false in the digital environment
into NaN. This is different from null. The object encapsulating it is Error.
Summary: Although the above content can be understood at a glance, I hope friends who are beginners like me will not be careless!
JavaScript Basics (2)
Basics
javascript: Declaration of variables
The following are several ways to declare variables
var value;
var value,value1,value2;//Declare multiple variables at the same time, but the values of these variables are all undefined
var i = 0,j = 0,k=100;/ /Variable declaration and initialization integrated.
//If you try to read a variable (value) that does not exist, an error will be reported! But if you try to assign a value to a variable that is not declared using Var, javascript
// will implicitly declare the variable, and the declared variable is still global. Details: So when everyone creates variables, try to use Var
//The scope of the variable (this problem is also easy to happen, everyone needs to understand it)
javascript: The scope of the variable
These It’s all details, and beginners like me must pay attention to avoid it!
var golbal = "golbal"; //global variable
var local = "local";
function area()
{
//The priority of local variables is higher than that of global variables
var local = "arealocal"
//When When the variable name declared in the function body is the same as the global variable name, JavaScript will hide the global variable
var golbal ="areagolbal";
document.write("local is :" local "and golbal is :" golbal "");
}
area();
//Output: local is :arealocaland golbal is :areagolbal
Define local in nested functions variables, what will be the effect? Look below:
var hope = "moremoney";
function createmore()
{
var hope = "have more money";//Partial
function createmoreto()//Nested function
{
var hope = "have more money to much";//Partial
document.write("Createmoreto hope is :" hope "
");
//Output:Createmoreto hope is :have more money to much
}
createmoreto();//Call
document.write("Createmore hope is :" hope "
");
//Output: Createmore hope is :have more money
}
createmore(); //Call
javascript: passing by value and passing by address
This is also an important concept! Don't miss it.
Pass by value and address
Copy the actual copied value , there are different ones. What is copied is only the reference to the number. If passed this
independent copy. The new reference modifies the value, and this change is visible to the original reference as well.
What is passed to the function is an independent copy of the value. What is passed to the function is a reference to the value. If the function
changes it, it has no effect outside the function. If the value is modified by the reference passed to it, this change
Changes are also visible.
Comparison Compares these two opposing values, usually comparing two references one by one to determine whether the
bytes they refer to are compared to determine whether they are equal to the same value.
javascript: basic types and reference types
The basic rules of javascript are: basic types are operated by passing by value, and reference types are operated by passing by address. (What is the value type, or what is the reference, please see my previous article)
Pass by value
var value = 1;
var copyvalue = value; //Assign value to another variable
function addTotal(total,arg)
{
total = arg; //total = total arg has the same effect as
}
//Call the function and pass two parameters (you may think that this function changes the value of the global variable, but in fact it does not. The function also uses opposite copy )
addTotal(value,copyvalue);
if(value == 1) copyvalue = 2;
document.write("total t" value "and copyvalue tt" copyvalue "
");
//Final output: total 1and copyvalue 2
Pass-by-address
var array = new Array("Javascccp");
var objarray = array;
function modifyArray(arr)
{
arr [0] = "JAVASCRIPT";
}
//Before calling the function
document.write(array[0] "
");
//Output Javascccp;
//After calling the function
modifyArray(array);
document.write(array[0] "
");
//Output uppercase JAVASCRIPT
// The same effect will be achieved by modifying objarray
objarray[0] = "Frank";
document.write(array[0] "
");
//Output Frank;
Summary: I hope everyone will not miss the above content, it is still very helpful for learning the following knowledge!

JavaScript is widely used in websites, mobile applications, desktop applications and server-side programming. 1) In website development, JavaScript operates DOM together with HTML and CSS to achieve dynamic effects and supports frameworks such as jQuery and React. 2) Through ReactNative and Ionic, JavaScript is used to develop cross-platform mobile applications. 3) The Electron framework enables JavaScript to build desktop applications. 4) Node.js allows JavaScript to run on the server side and supports high concurrent requests.

Python is more suitable for data science and automation, while JavaScript is more suitable for front-end and full-stack development. 1. Python performs well in data science and machine learning, using libraries such as NumPy and Pandas for data processing and modeling. 2. Python is concise and efficient in automation and scripting. 3. JavaScript is indispensable in front-end development and is used to build dynamic web pages and single-page applications. 4. JavaScript plays a role in back-end development through Node.js and supports full-stack development.

C and C play a vital role in the JavaScript engine, mainly used to implement interpreters and JIT compilers. 1) C is used to parse JavaScript source code and generate an abstract syntax tree. 2) C is responsible for generating and executing bytecode. 3) C implements the JIT compiler, optimizes and compiles hot-spot code at runtime, and significantly improves the execution efficiency of JavaScript.

JavaScript's application in the real world includes front-end and back-end development. 1) Display front-end applications by building a TODO list application, involving DOM operations and event processing. 2) Build RESTfulAPI through Node.js and Express to demonstrate back-end applications.

The main uses of JavaScript in web development include client interaction, form verification and asynchronous communication. 1) Dynamic content update and user interaction through DOM operations; 2) Client verification is carried out before the user submits data to improve the user experience; 3) Refreshless communication with the server is achieved through AJAX technology.

Understanding how JavaScript engine works internally is important to developers because it helps write more efficient code and understand performance bottlenecks and optimization strategies. 1) The engine's workflow includes three stages: parsing, compiling and execution; 2) During the execution process, the engine will perform dynamic optimization, such as inline cache and hidden classes; 3) Best practices include avoiding global variables, optimizing loops, using const and lets, and avoiding excessive use of closures.

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.


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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

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

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools