DemandThe list is sorted by an ID first, followed by an attribute with the same ID. Final Display effect:Implementation codevar Data.Items =[{' brand_id ':1,' farm_id ':2}, {' brand_id ':1,' farm_id ':3}, {' brand_id ':2,' farm_id ':4}]function Multisort(Array,...compairers){ return Array.Sort((A,b= { for(ConstC of Compairers){ ConstR= C(A,b; if(r!== 0){ returnR; } } });}Multisort(Data.Items,(A,b= a.brand_id - b.b
1. JS data types are divided into: numeric, Boolean, stringWith typeof you can see what the specific data type is.Example:2.js composite data type: divided into arrays, objects3. Special data type: null, var a=null;Undefine4.parseInt (); cast into integers;5. A+=90 =>a=a+90;B+=a =>b=b+a;B%a modulo, that is to take the remainder
I was in the debugging code, with the execution of JS code, generally by using alert in the code block to view the implementation of the JS code, today is also to see friends using the Console.log function to print output functions, variables, objects, The following is used to record the use of Console.log, the specific syntax is:
Console.log ("value is:", FN);
Console.log () Can output variabl
parameters:
If (engine implements invocable)
((invocable) engine). Invokefunction ("Afunction", param1, param2);
If the scripting language is Object oriented, you call can a as this:
Code View:
((invocable) engine). InvokeMethod (Implicitparam, "Amethod", explicitParam1, EXPLICITPARAM2);
6) Compiling a Script
Reader reader = new FileReader ("Myscript.js");
Compiledscript script = null;
If (engine implements compilable)
Compiledscript script = ((compilable) engine). compile (reader);
if
The page uses DateTimePicker to get the data type "12:12:12" if the input "11:11:11" to automatically calculate the time difference code as follows:
var a= "12:49:00", b= "14:49:00";
S=a.split (":");
E=b.split (":");
var Daya = new Date ();
var Dayb = new Date ();
Daya.sethours (S[0]);
Dayb.sethours (E[0]);
Daya.setminutes (S[1]);
Dayb.setminutes (e[1]);
Alert ("B more than A:" + (Dayb-daya)/1000/60+ "minutes")
The above JS time comparison
Hover mouse over the picture:
Onmouseover= "MouseOver ()" onmouseout= "Mouseout ()" >
JS Display weather forecast:
www.cxybl.com
"Http://m.weather.com.cn/m/pn11/weather.htm" width= "
JS use focus to achieve the choice of Web site:
www.cxybl.com
var i = 1;
var Focusid;
function Defau () {
document.getElementById ("1"). focus ();
focusid=1;
}
function showtable () {
var id = i + 1;
docume
JSON (JavaScript Object notation) is a lightweight data interchange format that takes a completely language-independent text format, and JSON is a JavaScript native data format.
Here are two ways of adding JSON data to JS arrays.
The first way
Personinfo
: [], for
(var i = 0; i
The second way
var passengerinfo = {};
Passengerinfo.psgtypedesc = Psgtypedesc;
Passengerinfo.flightprice = Flightprice;
_stage.passengerinfoarray.push
The code is very simple, the main idea is to parse the URL parameters to JS object, and then do add, delete, change, check the operation is very convenient ~, take notes here.
Copy Code code as follows:
var lg= (function (LG) {
var objurl=function (URL) {
this.ourl=url| | Window.location.href;
This.href= ""; the front part
This.params={};//url Parameter Object
This.jing= "";//#及后面部分
This.init ();
}
Parse the URL, get the front dep
JS can add delete picture upload box JS codeThis section of the program can detect the user upload picture type, size, before uploading, but also can increase the number of file upload, is the number of indeterminate files, imitation 51 space that file on the code
The looks like this:
More than this JS focus diagram, JS multiple pages to put multiple focus on the example is a small series to share all the content, hope to give you a reference, but also hope that we support the cloud habitat community.
This article brings you to the content is about JS in the definition of closure is what? JS closure of the application scenario, there is a certain reference value, there is a need for friends to refer to, I hope you have some help.
What is a closure package
Closures are functions that have access to variables in another function scope.
function Createfunc () { var name = "Wheeler"; return function (
Introduction to the most popular Node. js application development framework, node. js Application Development
Rapid development, easy scalability, high performance, and robust robustness. The emergence of Node. js makes these dreams of all network application developers a reality. However, like other new development language technologies, it is time-consuming t
This article mainly introduces node. buffer in js. description of the fill method. This article introduces the buffer. fill Method description, syntax, receiving parameters, use instances and implementation source code. For more information, see
Method description:
Fill the specified data in the buffer.
Syntax:
The Code is as follows:
Buffer. fill (value, [offset], [end])
Receiving parameters:
Data to be filled by value
The start positi
the function header.
All functions are defined before use.
Name constructors and callback functions as much as possible, so that you can see a clearer call stack during debugging.
Try to define all member functions in the constructor through the prototype, define the attributes in the constructor, and then use the new keyword to create an object for the constructor.
Avoid complex inheritance. If you want to inherit, use the inherits function in the util module whenever possible. For example
This article mainly introduces node. buffer in js. buffer. description of the isEncoding method. This article introduces the buffer. buffer. isEncoding method description, syntax, receive parameters, use instances, and implementation source code. For more information, see
Method description:
Checks whether it is a valid encoding parameter and returns true or false.
Syntax:
The Code is as follows:
Buffer. isEncoding (encoding)
Receiving parameters:
This article mainly introduces node. buffer in js. buffer. description of the isBuffer method. This article introduces the buffer. buffer. isBuffer method description, syntax, receiving parameters, use instances and implementation source code. For more information, see
Method description:
Checks whether the target is a buffer object. Returns true or false.
Syntax:
The Code is as follows:
Buffer. isBuffer (obj)
Receiving parameters:
Objec
This article mainly introduces node. console in js. this document describes how to use the time method. time Method description, syntax, receive parameters, use instances, and implement Source Code. For more information, see
Method description:
Start Time, which corresponds to console. timeEnd and records the time period.
Syntax:
The Code is as follows:
Console. time (label)
Receiving parameters:
The Label corresponds to the label of con
Refer to the Packaging tutorial:Http://www.cnblogs.com/tugenhua0707/p/4069769.htmlHttp://www.cnblogs.com/tugenhua0707/p/4982646.htmlHttp://www.tuicool.com/articles/viequayKey points of implementation:1, how to Run Gulp task, join the new good one the following tasks:// Grammar Check function () { gulp.src (' js/**/*.js '). Pipe (Jshint ()) . Pipe (Jshint.reporter (' default ')) ;});Then run
Introduction to Elasticlunr. js and introduction to elasticlunr. jsElasticlunr. js
Elasticlurn. js is a lightweight full-text search engine in Javascript for browser search and offline search.Elasticlunr. js is developed based on Lunr. js, but more flexible than lunr.
1, the key here is the value of the page, followed by the dynamic creation of an array, used to store the value$ (val). css ("Background-color", "RGB (251, 248, 233)");//Uncheckedvar ary;if (Crival_number.indexof (Fnumber) > 0) {var fnumbers = Crival_number.split (",");And then the operation is to remove the corresponding number from the Crival_numberary = new Array (fnumbers.length);for (var i = 0, j = 0; i if (fnumbers[i]! = Fnumber) {ARY[J] = fnumbers[i];}}}var str = "";if (Ary.length > 0) {f
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.