affect the external a variable;Parameters are reference types:1 //Reference type2 varperson = {name: ' Joel ', age:11}3 functionfoo (o) {4O.name = ' alen ';//change the value of an object5o = {name: ' Elire '}//change the address of an object6Console.log (O.name);//Elire7 }8 foo (person);9Console.log (Person.name);//AlenIf it is passed by reference, the O object passed in will be the same memory as the external person object, but the inte
'), User (' David '), Us ER (' big '), User (' Alen ')]
method, as before, defines a function that returns the value of the User's Name property, passing the function to the sorted key argument.
>>> user_list = [User (' John '), User (' David '), User (' big '), User (' Alen ')]
>>> sorted (user_list, Key=lambda x:x.name)
>>> sorted (user_list, Key=lambda x:x.name)
[User:alen, User:big, User:d
map()The function receives two parameters, one is a function, the other is a sequence, the map incoming function functions sequentially to each element of the sequence, and returns the result as a new list.For example, we have a function f (x) =x2, in order to function on a list, you [1, 2, 3, 4, 5, 6, 7, 8, 9] can use the implementation of the map() following:def f (x): return x*xmap (f,[1,2,3,4,5,6,7,8,9]Result[1, 4, 9, 16, 25, 36, 49, 64, 81]Reduce functions a function in a sequence [X1,
This article mainly introduces PHP to find two directory of relative path example (php to get relative path), need friends can refer to the followingTo find the relative path of two directories, do not limit the path depth code as follows:/** * Output $b relative to $a path ($a) * Unlimited path depth, no optimization, just implement function */function GetPath ($a, $b) {$AARR = E Xplode ('/', dirname ($a)); $BARR = explode ('/', dirname ($b)); $aLen
Question: Calculates the and of two digits.
Analysis: As we all know, number type of value has an upper limit, if it is two large numbers add sum, you cannot use the simplest + method, you can take two numbers as a string to deal with, starting from the end of the add, pay attention to the number of progressive digits, finally get the added string
Realize:
Arguments A, B are all string positive integers, sum
function Add (A, b) {
var aLen = a.length
); } } //here, the first character has not yet captured the corresponding parsing result, so exit if (!matched) { Break; } } //return the length of the invalid excess//if we ' re just parsing//Otherwise, throw an error or Return tokensIf the conversion returns the length of the selector that did not match successfully, the token is returned, and an error is thrown. Return parseonly?SoFar.length:soFar?Sizzle.error (selector)://Cache The TokensTokencache (selector,
// Use different color schemes for different numbers in the root category:// The initial order is: the URL sequence is the highest, followed by the cookie value.
// Extract the variable value from the URL stringFunction getqueryvalue (sorstr, panstr){VaR vstr = "";If (sorstr = NULL | sorstr = "" | panstr = NULL | panstr = "") return vstr;Sorstr = sorstr. tolowercase ();Panstr + = "= ";VaR itmp = sorstr. indexof (panstr );If (itmp Sorstr = sorstr. substr (itmp + panstr. Length );Itmp = sorstr. in
user name and password? If ($ count> = 1) (Well suppose there is, at least there should be = 1)3. Write a function to calculate the relative path of the two files.
For example:
$ A = '/A/B/C/D/E. php ';
$ B = '/a/B/12/34/C. php ';
Then, the relative path of $ a relative to $ B is ../C/D/E. php. For any two given directories (the directory format is valid and does not require verification ). Find the relative path of directory 1 to directory 2.
The original function is getrelativedir ($ dir1
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.