This translation is incomplete. Please help translate this article from English

.طريقة يمكنك تحقق بها إن كان نص يبدء بالعبارة ما و تعيد لك صحيح أو خطأ

تركيب الجملة | Syntax

str.startsWith(searchString[, position])

المعاملات | Parameters

العبارة المبحوث عنها فيالنص.
position Optional
مكان الذي يبدأ البحث منه فيالنص   الإفتراضي 0

القيمة العائدة | Return value

العائد يكون صحيح إذا وجد تطابق
و إن لم يجيد تطابق يعيد لك خطأ

الوصف | Description

هذه الطريقة حساسة إتجاه الحروف

أمثلة | Examples

Using startsWith()

var str = 'To be, or not to be, that is the question.';

console.log(str.startsWith('To be'));         // true
console.log(str.startsWith('not to be'));     // false
console.log(str.startsWith('not to be', 10)); // true


This method has been added to the ECMAScript 2015 specification and may not be available in all JavaScript implementations yet. However, you can polyfill String.prototype.startsWith() with the following snippet:

if (!String.prototype.startsWith) {
    Object.defineProperty(String.prototype, 'startsWith', {
        value: function(search, pos) {
            pos = !pos || pos < 0 ? 0 : +pos;
            return this.substring(pos, pos + search.length) === search;

A more robust (fully ES2015 specification compliant), but less performant and compact, Polyfill is available on GitHub by Mathias Bynens.


Specification Status Comment
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'String.prototype.startsWith' in that specification.
Standard Initial definition.
ECMAScript (ECMA-262)
The definition of 'String.prototype.startsWith' in that specification.
Living Standard

توافق مع متصفحات

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
startsWithChrome Full support 41Edge Full support 12Firefox Full support 17IE No support NoOpera Full support 28Safari Full support 9WebView Android Full support ≤37Chrome Android Full support 36Firefox Android Full support 17Opera Android Full support 24Safari iOS Full support 9Samsung Internet Android Full support 3.0nodejs Full support 4.0.0
Full support 4.0.0
Full support 0.12
Disabled From version 0.12: this feature is behind the --harmony runtime flag.


Full support  
Full support
No support  
No support
User must explicitly enable this feature.
User must explicitly enable this feature.

ذات صلة