Classes in JavaScript are represented by function functions, as follows:
CopyCode The Code is as follows: function student ()
{
// Define the field in the student class and grant the initial value. However, the access permission for this field is
CopyCodeThe Code is as follows: Document. writeln (" ",
" I ",
" name ",
" file name ",
" description ",
" Number of types ")
For (I = 0; I Document. writeln (" ", I,
"", navigator. plugins [I]. Name,
"", navigator. plugins [I]. filename,
The pre-loading technology mentioned in this article mainly enables javascript to quickly obtain the size of the image header data.
A typical example of getting the image size through pre-loading:Copy codeCode: var imgLoad = function (url, callback
No parameter class inheritance issues
Let's take A look at the sample code to implement B inherited from:Copy codeThe Code is as follows: function (){}A. prototype. a1 = function (){};
Function B (){}B. prototype = new ();B. prototype. b1 =
Let's simply download the htmlsource code (test2.htm ):
Copy codeThe Code is as follows:
2. debug and follow up in one stepLine-by-line analysis of jQuery source code is quite boring. In this case, I will use test2.htm as the target to
Copy codeThe Code is as follows: isArray: function (v ){
Return toString. apply (v) ===' [object Array] ';
},
IsDate: function (v ){
Return toString. apply (v) ===' [object Date] ';
},
IsObject: function (v ){
Return !! V & Object. prototype.
Note: When you add a string in firefox, the bug is that scrollTop will be equal to 0. Of course, the problem is solved, but it is not perfect. If you have already studied it, give me some advice.
Complete Test code:
Copy codeThe Code is as follows:
Yesterday, we used the jQuery plug-in aeImageResize to find it more advantageous: after each image is loaded, it will immediately perform proportional scaling.
This is attributed to the onload of the Image object loading event.
Check the source code
Writing maintainable Object-Oriented (OO) JavaScript will save you money and make you popular. Don't believe me? Odds are that either you or someone else will come back and work with your code. making that as painless an experience as possible will
Object creation declaration in javascript:Var obj = {}; or var obj = new Object ();
Add attributes to an object. Method:
// ======= First writing method ======================================== ======
Obj. name = 'xiaoming '; // adds attributes to
The sample code is as follows:
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
It only replaces the first letter. However, if you add a regular expression, the results will be different!
The event object is valid only when an event occurs. Some Properties of the event only make sense for specific events. For example, the fromElement and toElement attributes only make sense for onmouseover and onmouseout events. In the example below,
The following example shows a simpler method:
Save the Statistical Code to one file: file path:/config/counter. conf.
The Statistical Code is as follows:Copy codeThe Code is as follows:
We use StreamReader to read the file content, and the code
1. NaggingJavascript is an excellent scripting language. in addition to the flexibility of the scripting language, there are also many advanced language features. for example, a Garbage collection mechanism (GC: Garbage Collecation) is used to
1. Window object---------------------------------------------------------------------
Object Attributes
Window // The window itself
Window. self // reference this window = window. self
Window. name // name the window
Window. defaultStatus // set the
(1) simplified codeIt is very simple to define objects and arrays in JavaScript. We want to create an object, which is generally written as follows:
Copy codeThe Code is as follows: var car = new Object ();
Car. color = 'red ';
Car. wheels = 4;
Car.
There is no class definition in JavaScript. There is no fixed template when creating an object. You can dynamically create new attributes and Methods. When you dynamically create new attributes, what we can do is to create a new value for this
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