ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﺘﺷﺭ ﯼﻮﺠﺘﺴﺟ


فهرست مطالب

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

ﯼﺍ ﻪﺘﺷﺭ ﯼﻮﺠﺘﺴﺟ ﯼﺎﻫ ﺵﻭﺭ

  • String indexOf()
  • String lastIndexOf()
  • String search()
  • String match()
  • String matchAll()
  • String includes()
  • String startsWith()
  • String endsWith()

indexOf() ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﺘﺷﺭ

.ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ (ﺖﯿﻌﻗﻮﻣ) indexOf() index ﺵﻭﺭ

ﻝﺎﺜﻣ

let text = "Please locate where 'locate' occurs!";
let index = text.indexOf("locate");

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Strings</h1>
<h2>The indexOf() Method</h2>

<p>The indexOf() method returns the position of the first occurrence of a string in a string.</p>
<p>The position of the first occurrence of "locate" is:</p>
<p id="demo"></p>

<script>
let text = "Please locate where 'locate' occurs!";
let index = text.indexOf("locate");
document.getElementById("demo").innerHTML = index; 
</script>

</body>
</html>

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

.ﺩﺭﺎﻤﺷ ﯽﻣ ﺮﻔﺻ ﺯﺍ ﺍﺭ ﺎﻫ ﺖﯿﻌﻗﻮﻣ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ

ﺖﺳﺍ a ﺭﺩ ﺖﯿﻌﻗﻮﻣ ﻦﯿﻟﻭﺍ 0


()lastIndexOf ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﺘﺷﺭ

ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ ﻦﯾﺮﺧﺁ ﺺﺧﺎﺷlastIndexOf() ﺵﻭﺭ

ﻝﺎﺜﻣ

let text = "Please locate where 'locate' occurs!";
let index = text.lastIndexOf("locate");

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Strings</h1>
<h2>The lastIndexOf() Method</h2>

<p>The position of the last occurrence of "locate" is:</p>

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

<script>
let text = "Please locate where 'locate' occurs!";
let index = text.lastIndexOf("locate");
document.getElementById("demo").innerHTML = index;
</script>

</body>
</html>

ﺪﻨﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ code class="w3-codespan">lastIndexOf() -1> ﻢﻫ ﻭ indexOf()

ﻝﺎﺜﻣ

let text = "Please locate where 'locate' occurs!";
let index = text.lastIndexOf("John");

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Strings</h1>
<h2>The indexOf() Method</h2>

<p>Both indexOf() and lastIndexOf() return -1 if the text is not found:</p>
<p id="demo"></p>

<script>
let text = "Please locate where 'locate' occurs!";
let index = text.indexOf("John");
document.getElementById("demo").innerHTML = index;
</script>

</body>
</html>

ﺪﻧﺮﯾﺬﭘ ﯽﻣ ﻉﻭﺮﺷ ﺖﯿﻌﻗﻮﻣ ﻥﺍﻮﻨﻋ ﻪﺑ ﺍﺭ ﻡﻭﺩ ﺮﺘﻣﺍﺭﺎﭘ ﮏﯾ ﺵﻭﺭ ﻭﺩ ﺮﻫ

ﻝﺎﺜﻣ

let text = "Please locate where 'locate' occurs!";
let index = text.indexOf("locate", 15);

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Strings</h1>
<h2>The indexOf() Method</h2>

<p>The indexOf() method accepts a second parameter as the starting position for the search:</p>
<p id="demo"></p>

<script>
let text = "Please locate where 'locate' occurs!";
let index = text.indexOf("locate",15);
document.getElementById("demo").innerHTML = index; 
</script>

</body>
</html>

ﺪﻨﻨﮐﯽﻣ ﻮﺠﺘﺴﺟ ﺐﻘﻋ ﻪﺑ lastIndexOf() ﯼﺎﻫﺵﻭﺭ

ﻝﺎﺜﻣ

let text = "Please locate where 'locate' occurs!";
text.lastIndexOf("locate", 15);

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Strings</h1>
<h2>The lastIndexOf() Method</h2>

<p>The lastIndexOf() method accepts a second parameter as the starting position for the search.</p>
<p>Remember that the lastIndexOf() method searches backwards, so position 15 means start the search at position 15, and search to the beginning.</p>

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

<script>
let text = "Please locate where 'locate' occurs!";
let index = text.lastIndexOf("locate", 15);
document.getElementById("demo").innerHTML = index; 
</script>

</body>
</html>


()ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﺘﺷﺭ ﯼﻮﺠﺘﺴﺟ

.ﺪﻨﮐ ﯽﻣ ﻮﺠﺘﺴﺟ (ﻢﻈﻨﻣ ﺕﺭﺎﺒﻋ ﮏﯾ ﺎﯾ) ﻪﺘﺷﺭ ﮏﯾ ﯼﺍﺮﺑ ﺍﺭ ﻪﺘﺷﺭ ﮏﯾ search() ﺵﻭﺭ

ﺎﻫ ﻝﺎﺜﻣ

let text = "Please locate where 'locate' occurs!";
text.search("locate");

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Strings</h1>
<h2>The search() Method</h2>

<p>The search() method returns the position of the first occurrence of a string in a string.</p>
<p>The position of the first occurrence of "locate" is:</p>
<p id="demo"></p>

<script>
let text = "Please locate where 'locate' occurs!";
let index = text.search("locate");
document.getElementById("demo").innerHTML = index; 
</script>

</body>
</html>

let text = "Please locate where 'locate' occurs!";
text.search(/locate/);

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Strings</h1>
<h2>The search() Method</h2>

<p>The search() method returns the position of the first occurrence of a string in a string.</p>
<p>Return the position of the first occurrence of a regular expression:</p>
<p id="demo"></p>

<script>
let text = "Please locate where 'locate' occurs!";
let index = text.search(/locate/);
document.getElementById("demo").innerHTML = index;
</script>

</body>
</html>


؟ﺪﯾﺩﺮﮐ ﻪﺟﻮﺗ ﺎﯾﺁ

؟ﺪﻨﺘﺴﻫ ﺮﺑﺍﺮﺑsearch()، indexOf()

؟ﺪﻨﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ ﺭﺍﺪﻘﻣ ﻥﺎﻤﻫ ﻭ ﺪﻧﺮﯾﺬﭘ ﯽﻣ ﺍﺭ (ﺎﻫﺮﺘﻣﺍﺭﺎﭘ) ﺎﻫ ﻥﺎﻣﻮﮔﺭﺁ ﻥﺎﻤﻫ ﺎﻬﻧﺁ

:ﺪﻨﺘﺴﻫ ﺎﻫ ﺕﻭﺎﻔﺗ ﻦﯾﺍ .ﺪﻨﺘﺴﻫ ﺮﺑﺍﺮﺑ ﻪﻧ ﺵﻭﺭ ﻭﺩ ﻦﯾﺍ

  • .ﺩﺮﯿﮕﺑ ﺍﺭ ﻡﻭﺩ ﻉﻭﺮﺷ ﺖﯿﻌﻗﻮﻣ ﻥﺎﻣﻮﮔﺭﺁ ﺪﻧﺍﻮﺗ ﯽﻤﻧ search() ﺵﻭﺭ

  • ﺪﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﺪﻧﺍﻮﺗ ﯽﻤﻧ indexOf() ﺵﻭﺭ

ﺖﺧﻮﻣﺁ ﺪﯿﻫﺍﻮﺧ ﺮﺘﺸﯿﺑ ﻥﺁ ﺩﺭﻮﻣ ﺭﺩ



()ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﺘﺷﺭ ﺖﻘﺑﺎﻄﻣ

.ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ ﻖﺑﺎﻄﺗ ﺞﯾﺎﺘﻧ ﯼﻭﺎﺣ ﯼﺍﻪﯾﺍﺭﺁ match() ﺪﺘﻣ

ﺎﻫ ﻝﺎﺜﻣ

:ﺪﯿﻫﺩ ﻡﺎﺠﻧﺍ ﺍﺭ "ain" ﯼﻮﺠﺘﺴﺟ

let text = "The rain in SPAIN stays mainly in the plain"; 
text.match("ain"); 

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Strings</h1>
<h2>The match() Method</h2>

<p>Perform a search for "ain":</p>

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

<script>
let text = "The rain in SPAIN stays mainly in the plain";
const myArr = text.match("ain");
document.getElementById("demo").innerHTML = myArr.length + " " + myArr;
</script>

</body>
</html>

:ﺪﯿﻫﺩ ﻡﺎﺠﻧﺍ ﺍﺭ "ain" ﯼﻮﺠﺘﺴﺟ

let text = "The rain in SPAIN stays mainly in the plain"; 
text.match(/ain/); 

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Strings</h1>
<h2>The match() Method</h2>

<p>Perform a search for "ain":</p>

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

<script>
let text = "The rain in SPAIN stays mainly in the plain"; 
const myArr = text.match(/ain/);
document.getElementById("demo").innerHTML = myArr.length + " " + myArr;

</script>

</body>
</html>

:ﺪﯿﻫﺩ ﻡﺎﺠﻧﺍ "ain" ﯼﺍﺮﺑ ﯽﻧﺎﻬﺟ ﯼﻮﺠﺘﺴﺟ ﮏﯾ

let text = "The rain in SPAIN stays mainly in the plain"; 
text.match(/ain/g); 

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Strings</h1>
<h2>The match() Method</h2>

<p>Perform a global search for "ain":</p>

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

<script>
let text = "The rain in SPAIN stays mainly in the plain"; 
const myArr = text.match(/ain/g);
document.getElementById("demo").innerHTML = myArr.length + " " + myArr;
</script>

</body>
</html>

:ﺪﯿﻫﺩ ﻡﺎﺠﻧﺍ "ain" ﯼﺍﺮﺑ ﮒﺭﺰﺑ ﻑﻭﺮﺣ ﻥﻭﺪﺑ ﻭ ﯼﺮﺳﺍﺮﺳ ﯼﻮﺠﺘﺴﺟ ﮏﯾ

let text = "The rain in SPAIN stays mainly in the plain"; 
text.match(/ain/gi);

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Strings</h1>
<h2>The match() Method</h2>

<p>Perform a global, case-insensitive search for "ain":</p>

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

<script>
let text = "The rain in SPAIN stays mainly in the plain"; 
const myArr = text.match(/ain/gi);
document.getElementById("demo").innerHTML = myArr.length + " " + myArr;
</script>

</body>
</html>

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

،ﺪﺷﺎﺒﻧ (ﯽﻧﺎﻬﺟ ﯼﻮﺠﺘﺴﺟ) g ﻩﺪﻨﻨﮐ ﺡﻼﺻﺍ ﻞﻣﺎﺷ ﻢﻈﻨﻣ ﺕﺭﺎﺒﻋ ﮏﯾ ﺮﮔﺍ

.ﺪﯿﻧﺍﻮﺨﺑ ﺮﺘﺸﯿﺑ JS RegExp ﻞﺼﻓ ﺭﺩ ﻢﻈﻨﻣ ﺕﺍﺭﺎﺒﻋ ﻩﺭﺎﺑﺭﺩ


()matchAll ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﺘﺷﺭ

.ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ ﻖﺑﺎﻄﺗ ﺞﯾﺎﺘﻧ ﯼﻭﺎﺣ ﻩﺪﻨﻨﮐ ﺭﺍﺮﮑﺗ ﮏﯾ matchAll() ﺵﻭﺭ

ﻝﺎﺜﻣ

const iterator = text.matchAll("Cats");

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Strings</h1>
<h2>The matchAll() Method</h2>

<p>ES2020 intoduced the string method matchAll().</p>

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

<script>
let text = "I love cats. Cats are very easy to love. Cats are very popular."
const iterator = text.matchAll("Cats");

document.getElementById("demo").innerHTML = Array.from(iterator);
</script>

</body>
</html>

ﺕﺭﻮﺻ ﻦﯾﺍ ﺮﯿﻏ ﺭﺩ ،ﺩﻮﺷ ﻢﯿﻈﻨﺗ ﺪﯾﺎﺑ (g) ﯽﻧﺎﻬﺟ ﻢﭼﺮﭘ ،ﺖﺳﺍ ﻢﻈﻨﻣ ﺕﺭﺎﺒﻋ ﮏﯾ ﺮﺘﻣﺍﺭﺎﭘ ﺮﮔﺍ

ﻝﺎﺜﻣ

const iterator = text.matchAll(/Cats/g);

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Strings</h1>
<h2>The matchAll() Method</h2>

<p>ES2020 intoduced the string method matchAll().</p>

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

<script>
let text = "I love cats. Cats are very easy to love. Cats are very popular."
const iterator = text.matchAll(/Cats/g);

document.getElementById("demo").innerHTML = Array.from(iterator);
</script>

</body>
</html>

:ﺩﻮﺷ ﻢﯿﻈﻨﺗ ﺪﯾﺎﺑ (i) ﺱﺎﺴﺣ ﺮﯿﻏ ﻢﭼﺮﭘ ،ﺪﯿﻨﮐ ﻮﺠﺘﺴﺟ ﺱﺎﺴﺣ ﺮﯿﻏ ﻑﻭﺮﺣ ﺎﺑ ﺪﯿﻫﺍﻮﺧﯽﻣ ﺮﮔﺍ

ﻝﺎﺜﻣ

const iterator = text.matchAll(/Cats/gi);

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Strings</h1>
<h2>The matchAll() Method</h2>

<p>ES2020 intoduced the string method matchAll().</p>

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

<script>
let text = "I love cats. Cats are very easy to love. Cats are very popular."
const iterator = text.matchAll(/Cats/gi);

document.getElementById("demo").innerHTML = Array.from(iterator);
</script>

</body>
</html>

ﺖﺷﺍﺩﺩﺎﯾ

matchAll() ﯽﮔﮋﯾﻭ ﮏﯾ ES2020 ﺖﺳﺍ.

matchAll() ﺪﻨﮐ ﯽﻤﻧ ﺭﺎﮐ ﺭﺭﻮﻠﭙﺴﮐﺍ ﺖﻧﺮﺘﻨﯾﺍ ﺭﺩ.


()ﻞﻣﺎﺷ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﺘﺷﺭ

.ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ code class="w3-codespan">includes() true> ﺵﻭﺭ ،ﺪﺷﺎﺑ ﯽﺼﺨﺸﻣ ﺭﺍﺪﻘﻣ ﯼﻭﺎﺣ ﻪﺘﺷﺭ ﺮﮔﺍ

.ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ false ﺕﺭﻮﺻ ﻦﯾﺍ ﺮﯿﻏ ﺭﺩ

ﺎﻫ ﻝﺎﺜﻣ

:ﺖﺳﺍ "world" ﻞﻣﺎﺷ ﻪﺘﺷﺭ ﮏﯾ ﺎﯾﺁ ﻪﮐ ﺪﯿﻨﮐ ﯽﺳﺭﺮﺑ

let text = "Hello world, welcome to the universe.";
text.includes("world");

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Strings</h1>
<h2>The includes() Method</h2>

<p>Check if a string includes "world":</p>
<p id="demo"></p>

<p>The includes() method is not supported in Internet Explorer.</p>

<script>
let text = "Hello world, welcome to the universe.";
document.getElementById("demo").innerHTML = text.includes("world");
</script>

</body>
</html>

:ﺪﯿﻨﮐ ﻉﻭﺮﺷ 12 ﺖﯿﻌﻗﻮﻣ ﺯﺍ .ﺮﯿﺧ ﺎﯾ ﺖﺳﺍ "ﻥﺎﻬﺟ" ﻞﻣﺎﺷ ﻪﺘﺷﺭ ﮏﯾ ﺎﯾﺁ ﻪﮐ ﺪﯿﻨﮐ ﯽﺳﺭﺮﺑ

let text = "Hello world, welcome to the universe.";
text.includes("world", 12);

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Strings</h1>
<h2>The includes() Method</h2>

<p>Check if a string includes "world" starting from position 12:</p>
<p id="demo"></p>

<p>The includes() method is not supported in Internet Explorer.</p>

<script>
let text = "Hello world, welcome to the universe.";
document.getElementById("demo").innerHTML = text.includes("world", 12);
</script>

</body>
</html>

ﺖﺷﺍﺩﺩﺎﯾ

includes() ﺖﺳﺍ ﺱﺎﺴﺣ ﮒﺭﺰﺑ ﻭ ﮏﭼﻮﮐ ﻑﻭﺮﺣ ﻪﺑ.

includes() ﯽﮔﮋﯾﻭ ﮏﯾ ES6 ﺖﺳﺍ.

includes() ﯽﻤﻧ ﯽﻧﺎﺒﯿﺘﺸﭘ ﺭﺭﻮﻠﭙﺴﮐﺍ ﺖﻧﺮﺘﻨﯾﺍ ﺭﺩﺩﻮﺷ.


()startsWith ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﺘﺷﺭ

ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ startsWith() true ﺵﻭﺭ

:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ false ﺕﺭﻮﺻ ﻦﯾﺍ ﺮﯿﻏ ﺭﺩ

ﺎﻫ ﻝﺎﺜﻣ

:ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺖﺳﺭﺩ

let text = "Hello world, welcome to the universe.";
text.startsWith("Hello");

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Strings</h1>
<h2>The startsWith() Method</h2>
<p>Check if a string starts with "Hello":</p>

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

<p>The startsWith() method is not supported in Internet Explorer.</p>

<script>
let text = "Hello world, welcome to the universe.";
document.getElementById("demo").innerHTML = text.startsWith("Hello");
</script>

</body>
</html>

:ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ ﺖﺳﺭﺩﺎﻧ

let text = "Hello world, welcome to the universe.";
text.startsWith("world")

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Strings</h1>
<h2>The startsWith() Method</h2>

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

<p>The startsWith() method is not supported in Internet Explorer.</p>

<script>
let text = "Hello world, welcome to the universe.";
document.getElementById("demo").innerHTML = text.startsWith("world");
</script>

</body>
</html>

:ﺩﻮﺷ ﺺﺨﺸﻣ ﺪﻧﺍﻮﺗ ﯽﻣ ﻮﺠﺘﺴﺟ ﯼﺍﺮﺑ ﻉﻭﺮﺷ ﺖﯿﻌﻗﻮﻣ ﮏﯾ

:ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ ﺖﺳﺭﺩﺎﻧ

let text = "Hello world, welcome to the universe.";
text.startsWith("world", 5)

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Strings</h1>
<h2>The startsWith() Method</h2>

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

<p>The startsWith() method is not supported in Internet Explorer.</p>

<script>
let text = "Hello world, welcome to the universe.";
document.getElementById("demo").innerHTML = text.startsWith("world", 5);
</script>

</body>
</html>

:ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺖﺳﺭﺩ

let text = "Hello world, welcome to the universe.";
text.startsWith("world", 6)

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

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Strings</h1>
<h2>The startsWith() Method</h2>

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

<p>The startsWith() method is not supported in Internet Explorer.</p>

<script>
let text = "Hello world, welcome to the universe.";
document.getElementById("demo").innerHTML = text.startsWith("world", 6);
</script>

</body>
</html>

ﺖﺷﺍﺩﺩﺎﯾ

startsWith() ﺖﺳﺍ ﺱﺎﺴﺣ ﮒﺭﺰﺑ ﻭ ﮏﭼﻮﮐ ﻑﻭﺮﺣ ﻪﺑ.

startsWith() ﯽﮔﮋﯾﻭ ﮏﯾ ES6 ﺖﺳﺍ.

startsWith() ﺩﻮﺷ ﯽﻤﻧ ﯽﻧﺎﺒﯿﺘﺸﭘ ﺭﺭﻮﻠﭙﺴﮐﺍ ﺖﻧﺮﺘﻨﯾﺍ ﺭﺩ.


()endsWith ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﺘﺷﺭ

ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ endsWith() true ﺵﻭﺭ

:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ false ﺕﺭﻮﺻ ﻦﯾﺍ ﺮﯿﻏ ﺭﺩ

ﺎﻫ ﻝﺎﺜﻣ

:ﺩﻮﺷ ﯽﻣ ﻢﺘﺧ "Doe" ﻪﺑ ﻪﺘﺷﺭ ﮏﯾ ﺎﯾﺁ ﻪﮐ ﺪﯿﻨﮐ ﯽﺳﺭﺮﺑ

let text = "John Doe";
text.endsWith("Doe");

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

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Strings</h2>

<p>Check if a string ends with "Doe":</p>

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

<p>The endsWith() method is not supported in Internet Explorer.</p>

<script>
let text = "John Doe";
document.getElementById("demo").innerHTML = text.endsWith("Doe");
</script>

</body>
</html>

:ﺮﯿﺧ ﺎﯾ ﺩﻮﺷ ﯽﻣ ﻢﺘﺧ "world" ﻪﺑ ﻪﺘﺷﺭ ﮏﯾ ﻝﻭﺍ ﺮﺘﮐﺍﺭﺎﮐ 11 ﺎﯾﺁ ﻪﮐ ﺪﯿﻨﮐ ﯽﺳﺭﺮﺑ

let text = "Hello world, welcome to the universe.";
text.endsWith("world", 11);

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

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Strings</h2>

<p>Check in the 11 first characters of a string ends with "world":</p>

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

<p>The endsWith() method is not supported in Internet Explorer.</p>

<script>
let text = "Hello world, welcome to the universe.";
document.getElementById("demo").innerHTML = text.endsWith("world", 11);
</script>

</body>
</html>

ﺖﺷﺍﺩﺩﺎﯾ

endsWith() ﺖﺳﺍ ﺱﺎﺴﺣ ﮒﺭﺰﺑ ﻭ ﮏﭼﻮﮐ ﻑﻭﺮﺣ ﻪﺑ.

endsWith() ﯽﮔﮋﯾﻭ ﮏﯾ ES6 ﺖﺳﺍ.

endsWith() ﯽﻤﻧ ﯽﻧﺎﺒﯿﺘﺸﭘ ﺭﺭﻮﻠﭙﺴﮐﺍ ﺖﻧﺮﺘﻨﯾﺍ ﺭﺩﺩﻮﺷ.


ﻪﺘﺷﺭ ﻞﻣﺎﮐ ﻊﺟﺮﻣ

:ﺪﯾﻭﺮﺑ ﺎﻣ ﺱﺭﺩﺁ ﻪﺑ ،ﻪﺘﺷﺭ ﻞﻣﺎﮐ ﻊﺟﺮﻣ ﮏﯾ ﯼﺍﺮﺑ

.ﺪﯿﻨﮐ ﻞﻣﺎﮐ ﺍﺭ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﺘﺷﺭ ﻊﺟﺮﻣ

.ﺖﺳﺍ ﻪﺘﺷﺭ ﯼﺎﻫ ﺵﻭﺭ ﻭ ﺎﻫ ﯽﮔﮋﯾﻭ ﻡﺎﻤﺗ ﺯﺍ ﯽﯾﺎﻫ ﻪﻧﻮﻤﻧ ﻭ ﺕﺎﺤﯿﺿﻮﺗ ﯼﻭﺎﺣ ﻊﺟﺮﻣ

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