ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫ ﺱﺎﻤﺗ


فهرست مطالب

    نمایش فهرست مطالب

"ﺖﻓﺮﮔ ﻢﻫﺍﻮﺧ ﺱﺎﻤﺗ ﺍًﺪﻌﺑ!"

ﺩﻮﺷ ﯽﻣ ﻝﺎﺳﺭﺍ ﯼﺮﮕﯾﺩ ﻊﺑﺎﺗ ﻪﺑ ﻥﺎﻣﻮﮔﺭﺁ ﻥﺍﻮﻨﻋ ﻪﺑ ﻪﮐ ﺖﺳﺍ ﯽﻌﺑﺎﺗ ﻥﺍﻮﺧﺍﺮﻓ ﺖﺸﮔﺮﺑ

ﺪﻨﮐ ﯽﻧﺍﻮﺧﺍﺮﻓ ﺍﺭ ﯼﺮﮕﯾﺩ ﻊﺑﺎﺗ ﺎﺗ ﺪﻫﺩ ﯽﻣ ﻩﺯﺎﺟﺍ ﻊﺑﺎﺗ ﮏﯾ ﻪﺑ ﮏﯿﻨﮑﺗ ﻦﯾﺍ

ﺩﻮﺷ ﺍﺮﺟﺍ ﺮﮕﯾﺩ ﺩﺮﮑﻠﻤﻋ ﻡﺎﻤﺗﺍ ﺯﺍ ﺲﭘ ﺪﻧﺍﻮﺗ ﯽﻣ ﯽﻧﺍﻮﺧﺍﺮﻓ ﻊﺑﺎﺗ ﮏﯾ

ﻊﺑﺍﻮﺗ ﯽﻟﺍﻮﺗ

.ﺪﻧﻮﺷ ﯽﻣ ﺍﺮﺟﺍ ﺪﻧﻮﺷ ﯽﻣ ﻩﺪﯿﻣﺎﻧ ﻪﮐ ﯽﺒﯿﺗﺮﺗ ﻪﺑ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻊﺑﺍﻮﺗ

:ﺪﻫﺩ ﯽﻣ ﺶﯾﺎﻤﻧ ﺍﺭ "Goodbye" ﺖﯾﺎﻬﻧ ﺭﺩ ﻝﺎﺜﻣ ﻦﯾﺍ

ﻝﺎﺜﻣ

 function myFirst() {
  myDisplayer("Hello");
}
function 
  mySecond() {
  
  myDisplayer("Goodbye");
}
myFirst();
mySecond();

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Functions</h1>
<h2>Function Sequence</h2>
<p>JavaScript functions are executed in the sequence they are called.</p>

<p id="demo"></p>

<script>
function myDisplayer(some) {
  document.getElementById("demo").innerHTML = some;
}

function myFirst() {
  myDisplayer("Hello");
}

function mySecond() {
  myDisplayer("Goodbye");
}

myFirst();
mySecond();
</script>

</body>
</html>

:ﺪﻫﺩ ﯽﻣ ﺶﯾﺎﻤﻧ ﺍﺭ "Hello" ﺖﯾﺎﻬﻧ ﺭﺩ ﻝﺎﺜﻣ ﻦﯾﺍ

ﻝﺎﺜﻣ

 function myFirst() {
  myDisplayer("Hello");
}
function 
  mySecond() {
  
  myDisplayer("Goodbye");
}
mySecond();
myFirst();

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Functions</h1>
<h2>Function Sequence</h2>
<p>JavaScript functions are executed in the sequence they are called.</p>

<p id="demo"></p>

<script>
function myDisplayer(some) {
  document.getElementById("demo").innerHTML = some;
}

function myFirst() {
  myDisplayer("Hello");
}

function mySecond() {
  myDisplayer("Goodbye");
}

mySecond();
myFirst();
</script>

</body>
</html>

ﯽﻟﺍﻮﺗ ﻝﺮﺘﻨﮐ

.ﺪﯿﺷﺎﺑ ﻪﺘﺷﺍﺩ ﻊﺑﺎﺗ ﮏﯾ ﯼﺍﺮﺟﺍ ﻥﺎﻣﺯ ﯼﻭﺭ ﯼﺮﺘﻬﺑ ﻝﺮﺘﻨﮐ ﺪﯾﺭﺍﺩ ﺖﺳﻭﺩ ﺕﺎﻗﻭﺍ ﯽﻫﺎﮔ

.ﺪﯿﻫﺩ ﺶﯾﺎﻤﻧ ﺍﺭ ﻪﺠﯿﺘﻧ ﺲﭙﺳ ﻭ ﺪﯿﻫﺩ ﻡﺎﺠﻧﺍ ﻪﺒﺳﺎﺤﻣ ﮏﯾ ﺪﯿﻫﺍﻮﺧ ﯽﻣ ﺪﯿﻨﮐ ﺽﺮﻓ

.ﺪﯿﻨﮐ ﻩﺮﯿﺧﺫ ﺍﺭ ﻪﺠﯿﺘﻧ ،ﺪﯿﻨﮐ ﯽﻧﺍﻮﺧﺍﺮﻓ ﺍﺭ myCalculator)

ﻝﺎﺜﻣ

function myDisplayer(some) {
  document.getElementById("demo").innerHTML = some;
}

function myCalculator(num1, num2) {
  let sum = num1 + num2;
  return sum;

}
let result = myCalculator(5, 5);
myDisplayer(result);

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Functions</h1>
<h2>Function Sequence</h2>
<p>JavaScript functions are executed in the sequence they are called.</p>

<p>The result of the calculation is:</p>
<p id="demo"></p>

<script>
function myDisplayer(some) {
  document.getElementById("demo").innerHTML = some;
}

function myCalculator(num1, num2) {
  let sum = num1 + num2;
  return sum;
}

let result = myCalculator(5, 5);
myDisplayer(result);
</script>

</body>
</html>

.ﺪﯿﻨﮐ ﯽﻧﺍﻮﺧﺍﺮﻓ ﺍﺭ (myCalculator) ﺏﺎﺴﺣ ﻦﯿﺷﺎﻣ ﻊﺑﺎﺗ ﮏﯾ

ﻝﺎﺜﻣ

 function myDisplayer(some) {
  document.getElementById("demo").innerHTML 
  = some;
}
function myCalculator(num1, num2) {
  
  let sum = num1 + num2;
  
  myDisplayer(sum);
}
myCalculator(5, 5);

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Functions</h1>
<h2>Function Sequence</h2>
<p>JavaScript functions are executed in the sequence they are called.</p>

<p>The result of the calculation is:</p>
<p id="demo"></p>

<script>
function myDisplayer(some) {
  document.getElementById("demo").innerHTML = some;
}

function myCalculator(num1, num2) {
  let sum = num1 + num2;
  myDisplayer(sum);
}

myCalculator(5, 5);
</script>

</body>
</html>

.ﺪﯿﻨﮐ ﯽﻧﺍﻮﺧﺍﺮﻓ ﺍﺭ ﻊﺑﺎﺗ ﻭﺩ ﺪﯾﺎﺑ ﻪﺠﯿﺘﻧ ﺶﯾﺎﻤﻧ ﯼﺍﺮﺑ ﻪﮐ ﺖﺳﺍ ﻦﯾﺍ ﻻﺎﺑ ﻝﻭﺍ ﻝﺎﺜﻣ ﻞﮑﺸﻣ

ﺪﯿﻨﮐ ﯼﺮﯿﮔﻮﻠﺟ ﺏﺎﺴﺣ ﻦﯿﺷﺎﻣ ﺩﺮﮑﻠﻤﻋ ﺯﺍ ﺪﯿﻧﺍﻮﺗ ﯽﻤﻧ ﻪﮐ ﺖﺳﺍ ﻦﯾﺍ ﻡﻭﺩ ﻝﺎﺜﻣ ﻞﮑﺸﻣ

.ﺪﯿﻨﮐ ﺩﺭﺍﻭ ﯽﺘﺸﮔﺮﺑ ﺱﺎﻤﺗ ﮏﯾ ﻪﮐ ﺖﺳﺍ ﻥﺁ ﻥﺎﻣﺯ ﻥﻮﻨﮐﺍ



ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫ ﺱﺎﻤﺗ

.ﺩﻮﺷ ﯽﻣ ﻝﺎﺳﺭﺍ ﯼﺮﮕﯾﺩ ﻊﺑﺎﺗ ﻪﺑ ﻥﺎﻣﻮﮔﺭﺁ ﻥﺍﻮﻨﻋ ﻪﺑ ﻪﮐ ﺖﺳﺍ ﯽﻌﺑﺎﺗ ﻥﺍﻮﺧﺍﺮﻓ ﺖﺸﮔﺮﺑ

.ﺪﯿﻨﮐ ﯽﻧﺍﻮﺧﺍﺮﻓ ﺍﺭ (myCalculator) ﺏﺎﺴﺣ ﻦﯿﺷﺎﻣ ﻊﺑﺎﺗ ﺪﯿﻧ

ﻝﺎﺜﻣ

 function myDisplayer(some) {
  document.getElementById("demo").innerHTML 
  = some;
}
function myCalculator(num1, num2, myCallback) {
  
  let sum = num1 + num2;
  
  myCallback(sum);
}
myCalculator(5, 5, myDisplayer);

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Functions</h1>
<h2>Callback Functions</h2>

<p>The result of the calculation is:</p>
<p id="demo"></p>

<script>
function myDisplayer(something) {
  document.getElementById("demo").innerHTML = something;
}

function myCalculator(num1, num2, myCallback) {
  let sum = num1 + num2;
  myCallback(sum);
}

myCalculator(5, 5, myDisplayer);
</script>

</body>
</html>

.ﺩﻮﺷ ﯽﻣ ﻩﺪﯿﻣﺎﻧ ﺱﺎﻤﺗ ﻪﺑ ﺖﺸﮔﺮﺑ ﺩﺮﮑﻠﻤﻋ ﮏﯾ myDisplayer

.ﺩﻮﺷ ﯽﻣ ﻝﺎﺳﺭﺍ myCalculator() ﻪﺑ argument ﻥﺍﻮﻨ

ﺪﯿﺷﺎﺑ ﻪﺘﺷﺍﺩ ﻪﺟﻮﺗ

.ﺪﯿﻨﮑﻧ ﻩﺩﺎﻔﺘﺳﺍ ﺰﺘﻧﺍﺮﭘ ﺯﺍ ﻪﮐ ﺪﯿﺷﺎﺑ ﻪﺘﺷﺍﺩ ﺩﺎﯾ ﻪﺑ ،ﺪﯿﻨﮐ ﯽﻣ ﻝﺎﺳﺭﺍ ﻥﺎﻣﻮﮔﺭﺁ ﻥﺍﻮﻨﻋ ﻪﺑ ﺍﺭ ﯽﻌﺑ

؛myCalculator (5، 5، myDisplayer) :ﺖﺳﺍﺭ ﺖﻤﺳ

;myCalculator(5, 5, myDisplayer()) :ﻩﺎﺒﺘﺷﺍ

ﻝﺎﺜﻣ

// Create an Array
const myNumbers = [4, 1, -20, -7, 5, 9, -6];

// Call removeNeg with a callback
const posNumbers = removeNeg(myNumbers, (x) => x >= 0);

// Display Result
document.getElementById("demo").innerHTML = posNumbers;

// Keep only positive numbers
function removeNeg(numbers, callback) {
  const myArray = [];
  for (const x of numbers) {
    if (callback(x)) {
      myArray.push(x);
    }
  }
  return myArray;
}

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body style="text-align: right">

<h1>JavaScript Functions</h1>
<h2>Callback Functions</h2>
<p id="demo"></p>

<script>
// Create an Array
const myNumbers = [4, 1, -20, -7, 5, 9, -6];

// Call removeNeg with a Callback
const posNumbers = removeNeg(myNumbers, (x) => x >= 0);

// Display Result
document.getElementById("demo").innerHTML = posNumbers;

// Remove negative numbers
function removeNeg(numbers, callback) {
  const myArray = [];
  for (const x of numbers) {
    if (callback(x)) {
      myArray.push(x);
    }
  }
  return myArray;
}
</script>

</body>
</html>

.ﺖﺳﺍ ﺱﺎﻤﺗ ﻪﺑ ﺦﺳﺎﭘ ﺩﺮﮑﻠﻤﻋ ﮏﯾ (x) => x >= 0 ،ﻻﺎ

.ﺩﻮﺷ ﯽﻣ ﻝﺎﺳﺭﺍ removeNeg() ﻪﺑ argument ﻥﺍﻮﻨﻋ ﻪ


؟ﻢﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﺱﺎﻤﺗ ﻪﺑ ﺦﺳﺎﭘ ﺯﺍ ﯽﻧﺎﻣﺯ ﻪﭼ

.ﺪﻨﺘﺴﯿﻧ ﺰﯿﮕﻧﺍ ﻥﺎﺠﯿﻫ ﯽﻠﯿﺧ ﻻﺎﺑ ﯼﺎﻫ ﻝﺎﺜﻣ

.ﺪﻧﺍ ﻩﺪﺷ ﻩﺩﺎﺳ ﺎﻤﺷ ﻪﺑ ﺖﺸﮔﺮﺑ ﻮﺤﻧ ﺵﺯﻮﻣﺁ ﯼﺍﺮﺑ ﺎﻬﻧﺁ

،ﺪﻨﺘﺴﻫ ﻥﺎﻣﺰﻤﻫﺎﻧ ﻊﺑﺍﻮﺗ ﺭﺩ ،ﺪﻨﺸﺧﺭﺩﯽﻣ ﺎًﻌﻗﺍﻭ ﯽﺘﺸﮔﺮﺑ ﯼﺎﻫﺱﺎﻤﺗ ﻪﮐ ﯽﯾﺎﺟ

.ﺖﺳﺍ ﻩﺪﺷ ﻩﺩﺍﺩ ﺶﺷﻮﭘ ﯼﺪﻌﺑ ﻞﺼﻓ ﺭﺩ ﻥﺎﻣﺰﻤﻫﺎﻧ ﻊﺑﺍﻮﺗ

تمامی حقوق محفوظ است. © BasicIT.org • 2023-2024