The difference between JavaScript and the function of PHP and Python

Source: Internet
Author: User

1. JavaScript function Type:

(a), the first kind

function Test (param) {    return 111;}

(ii), the second type of

var function (param) {    return 222;}

Note: Inside the applet is param:function () {

}
This is actually the same wording!

(iii), the third type of

var k = (param) ==    {return 111;}

Note: The second and third types can be used in callback functions!

2. php function Type:

function Test ($param) {        return 111;}
$callback=function() {  return ' AA 'echo $callback

Note: PHP and JavaScript function basically the same way, but it seems that PHP does not have an arrow function.

3. Python's function notation

(a), the first kind

# Defining Functions def printme (str):    " print any passed-in string "   Print str;    return  #  call function printme (" I want to invoke user-defined function! ");

(ii), the second type of

Lambda x,y:x*yprint R (2,3)

Summary: Each major programming language contains a general definition of the function, and anonymous functions, anonymous functions are generally used in the callback function!

The difference between JavaScript and the function of PHP and Python

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.