JavaScript learning the first JS Foundation
1, javascript Character set:
JavaScript uses the Unicode character set encoding.
Why do you use this code?
The reason is simple, 16-bit Unicode encoding can represent any written language of the Earth people. This is an important feature of language internationalization. (You may have seen a script written in Chinese,
delivered by the server and loaded by the browser, the client script allows users to interact with the webpage. For example, Google Maps uses JavaScript to support interaction between users and Maps. The interaction methods include moving Maps, enlarging and narrowing down. Without the JavaScript language, the webpage needs to refresh the interaction behavior with each user each time, unless the page uses
string type: string (); for example, the result of string (678) is "678"2. Convert to numeric type: Number (); for example, the result of number ("678") is 678.3. Convert to boolean: Boolean (); for example, Boolean ("AAA") returns true
How to extract another type of value from one value:
1. Extract the integer parseint () in the string. For example, the result of parseint ("123 Zhang") is 123.2. Extract the floating point: parsefloat () in the strin
();var b=new Object ();A.obj=b;B.obj=a;In this function, A and B are referenced by each other by their respective properties. That is, the number of references to both is 2. This is embarrassing, when the function is finished, the two references are not 0, then the way to reference the count is not. If this method is executed multiple times, the variables inside will accumulate, which is not the result we want to see. We know that some of the obje
Callback functions are very important in JavaScript and they are almost ubiquitous. Like other more traditional programming languages, there is a callback function concept, but it is very strange that there are few online tutorials to talk about the callback function, but there is a bunch of call () and apply () functions, or some short examples of using callback.Functions are also objectsTo figure out the callback function, you first have a clear und
Javascript 2 is coming up.This is not the news, but the news seems to have not circulated at home. Anyway, I'll just turn to the relevant information.http://developer.mozilla.org/presentations/xtech2006/javascript/ This is an introduction to the language features of JavaScript 2
inspiration that prompted me to create the popular data Interchange Format--json.
JavaScript relies on global variables to connect, and all top-level variables of all compilation units are set up in a common namespace called global objects. This is a bad thing, because global variables are demons, and they are fundamental in JavaScript.
javascript reserved wor
JavascripJavaScript is a programming language, and the browser has a JavaScript interpreter in it, so the browser can interpret and handle the code after it is written in the JavaScript language rules. First, how to write1. JavaScript code exists in form--方式一-->type="text/javascript"src="JS文件">/script>--方式二-->type="tex
chain to inherit the bridge parent class */subclass.prototype=new bridge (); subclass.prototype.constructor=subclass;/* the third step : Extended subclass Properties, referring to the parent class as a shared property of the subclass, called in the subclass of */SubClass.prototype.superClass=SuperClass.prototype; // here must be prototype, not the function itself *//Fourth step : to ensure the normal operation of the program mechanism, Make a little judgment */if (SuperClass.prototype.construc
/*Basic JavaScript Learning SummaryThis summary uses the DW to write, in order to debug conveniently, will affect the test part to write in the annotation form ****/All tests are shown with the alert () function1, if conditional sentence function funif () {var date = new Date ();//Get a new datevar time = date.gethours ();//Get the current hour from the dateif (Time Alert ("Good morning!" ");}else if (Time Alert ("Noon!");}else if (Time Alert ("The Af
differently depending on the position of the parentheses-this is because the semicolon insertion mechanism , when you choose to end a line of code without a semicolon, will fix it for you.This behavior can cause trouble, such as when you return an object literal, while the opening parenthesis is on the next line:You will be surprised if you want the function to return an object that contains the name attribute. Because of the implicit semicolon, the function returns undefined. The preceding cod
, this usage is not a good habit and is not recommended for everyone to use. Essentially, when you create an associative array, you create an array object's properties. In JavaScript, all variables are actually objects of some kind. For example, a Boolean value is an object of type Boolean. In the above example, you are actually adding the name, year, and living three properties to the lemon array. Ideally, you should not modify the properties of an a
have any connection.Because the capture is X's reference, so the above three functions see X is the same variable.This is important because the local variables in JavaScript are not all in the heap . At least GOOGLE V2 is not. But the x above line 3 must be "Born and live" in the heap , otherwise func1,get1, Get2 will work on the destroyed stack variable x , making the above program meaningless.In other words, the runtime cost of closures is to t
Many come to the cloud habitat community are to directly know how to use, here first directly give the common fault-tolerant code.
The first: The cloud-dwelling community itself is using
Copy Code code as follows:
More reference to JavaScript fault-tolerant processing code (masking JS error)
If a more detailed description can continue to look down.
If the exception-handling code is well-designed, then the final presentation t
when convertingPaesrfloat() floating point numberParsefloat: Parses each character starting from the first string until it encounters an invalid floating-point number character. Note: In addition to the first decimal point,the second difference between parsefloat () and parseint () is that it will always ignore the leading 0. JavaScript Data TypesLearning Goals1. Mastering String2. Mastering the string tur
of 0 ~ 1;Math.max () \math.min ();MATH.AQRT () = calculates the square root;MATH.PSW (J, I); + = Calculates the i-th square of J;Math.floor (); = Math.floor (1.5) + 1;Math.ceil (); = Math.ceil (1.2) + 2;Math.Round (); = Math.Round (1.2) + 1; Math.Round (1.5) = 2;Math.sin () = Returns the sine of the specified number of degrees;Math.Cos () = Returns the cosine of the specified number of degrees;Math.atan2 (
can arbitrarily define a global variable anywhere. Small application seems very convenient, code into scale, after splitting the file, it is finished. Compiler regardless, we can tube.Two different ways:1. All written together, such as the top of the program, good management.2. Write a container of global variables and throw all the global variables in when you use them. Such benefits are also unified management for convenient retrieval.var variableb
Grammar:1. Case-sensitive!!2. Identifier: variable, function name, property name, parameter.1. The first character must be a letter, _, or $2. Other characters can be letters, _,, or numbers3. Notes:1. Single-line Comment://2. Multiline Comment:/* */4. Strict mode: Specify "Use strict" at the beginning of the function bodyfunction do () { "user strict"; fun
This program can be used to implement many common animation effects, including size conversion, location conversion, and fade-in and fade-out.Program Description: The principle of gradient effect is to use the timer to continuously set the value. If you want to slow down the effect, set a step (For details, refer to the JavaScript spring effect ).Here we only integrate the gradient properties (transparency, width, height, left, top) and use the same g
will return a value, and let the function end.function myFunction () { var x=5; return x;}The above function returns the value 5.Example:function MyFunction (b) { return A *b;} document.getElementById ("Demo"). innerhtml= MyFunction (4,3);The InnerHTML of the "demo" element will be: 12You can also use the return statement only if you want to exit the function. The return value is optional:function MyFunction (b) { if (a>b) { return; } x=a+B}If a is greater than B, t
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.