Js กลับมาฟังก์ชัน

รหัสตัวอย่าง

4
0

N

function test(arg){
    return arg;
}
3
0

N

function addfunc(a, b) {
  return a + b;
  // standard long function
}

addfunc = (a, b) => { return a + b; }
// cleaner faster way creating functions!
1
0

N

function myFunction(p1, p2) {
  var a = "";
  $.ajax({
    method: "POST",
    url: "/url",
    data: {p1: p1,p2: p2},
    success: function (data) {a = data.result;},
    error: function (data) {a = data.result;}
    });
  return a;
}
1
0

N

function myFunction(p1, p2) {
  var a = "";
 $.post( "/url", function( data ) {a = data.result;});
  return a;
}
1
0

N

Babel compiles "javascript return" (depending on quantum airspeed) into either:
"The return of the Javascript" Javascript dialect spoken on Java, or 
the second sequel in the zombie series inwhich 
Javas's crypt on Tatooine, spawns millions of ravenous 
enterprise applications that supress the rebellion's ability to use Node.
1
0

N

<script>
function showName() {
  var result;
  result = addString('Hello', ' World');
  document.write (result );
}

// in below we will check how to return string from function
function addString(fName, lName) {
  var val;
  val = fName + lName;
  return val;  // returning string from function
}
</script>
<input type = "button" onclick = "showName()" value = "Result">
  
/*
I hope it will help you.
Namaste
Stay Home Stay Safe
*/

ในภาษาอื่นๆ

หน้านี้อยู่ในภาษาอื่นๆ

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................