mozilla
Your Search Results

    Boolean

    סיכום

    Boolean הוא אובייקט מעטפת עבור ערך בוליאני (ערכי אמת ושקר, true, false)

    תחביר

    new Boolean(value)

    פרמטרים

    value
    ערך האיתחול של אובייקט Boolean.

    תיאור

    הערך המועבר כפרמטר הראשון מומר לערך בוליאני אם אינו כזה. אם לא קיים ערך, או שערכו הוא 0, 0-, null, false, NaN, undefined או מחרוזת ריקה ("") - אזי האובייקט מאותחל עם ערך שקרי (false). כל ערך אחר, כולל אובייקטים ואפילו המחרוזת "false" מאתחלים את האובייקט עם ערך אמת (true).

    בתוך תנאי - כל אובייקט שערכו אינו undefined או null, כולל האובייקט Boolean שאותחל עם ערך שקר - נחשב כאמת. התנאי בדוגמה הבאה נחשב כאמת:

    x = new Boolean(false);
    if (x) {
      // . . . this code is executed
    }
    

    התנהגות זו אינה חלה כמובן על טיפוס בוליאני פשוט. התנאי בדוגמה הבאה נחשב שקר:

    x = false;
    if (x) {
      // . . . this code is not executed
    }
    

    אין להשתמש באובייקט Boolean על מנת להמיר ערך לא בוליאני - לבוליאני. לצורך זה יש להשתמש ב-Boolean כפונקציה:

    x = Boolean(expression);     // preferred
    x = new Boolean(expression); // don't use
    

    ערכו של אובייקט Boolean שאותחל באמצעות כל אובייקט, כולל אובייקט מסוג Boolean שאותחל באמצעות false, הוא אמת:

    myFalse = new Boolean(false);   // initial value of false
    g = new Boolean(myFalse);       // initial value of true
    myString = new String("Hello"); // string object
    s = new Boolean(myString);      // initial value of true
    

    אין להשתמש באובייקט Boolean במקום הטיפוס הפשוט אותו הוא עוטף.

    מאפיינים

    For properties available on Boolean instances, see Properties of Boolean instances.

    prototype: מאפיין משותף לכל המופעים של של Boolean.

     
    /** 
     * Replaces Template:JSInherits. Given an object and a list of properties or 
     * methods implemented elsewhere, output a list of the properties or methods 
     * inherited from that object. 
     * 
     * TODO: make it work with an inheritance chain, e.g., if you want inherited 
     * properties or methods from both Function and Object, where Function itself 
     * overrides methods from Object. We don't want to see that it inherits a 
     * "valueOf" method from Function and again on Object. 
     * 
     * @param the object to inherit from 
     * @param "properties" or "methods" 
     * @param a list of properties or methods overridden by this object 
     */ 
    var hedict = { 
    properties : 'מאפיינים היורשים', 
    methods: 'מתודות היורשות' 
    }; 
    var prototypes = { 
      Array: { 
        methods: [ 
          "pop", 
          "push", 
          "reverse", 
          "shift", 
          "sort", 
          "splice", 
          "unshift", 
          "concat", 
          "join", 
          "slice", 
          "toSource", 
          "toString", 
          "indexOf", 
          "lastIndexOf", 
          "filter", 
          "forEach", 
          "every", 
          "map", 
          "some", 
          "reduce", 
          "reduceRight" 
        ], 
        properties: [ 
          "constructor", 
          "index", 
          "input", 
          "length" 
        ] 
      }, 
      Boolean: { 
        methods: [ 
          "toSource", 
          "toString", 
          "valueOf" 
        ], 
        properties: [ 
          "constructor" 
        ] 
      }, 
      Date: { 
        methods: [ 
          "getDate", 
          "getDay", 
          "getFullYear", 
          "getHours", 
          "getMilliseconds", 
          "getMinutes", 
          "getMonth", 
          "getSeconds", 
          "getTime", 
          "getTimezoneOffset", 
          "getUTCDate", 
          "getUTCDay", 
          "getUTCFullYear", 
          "getUTCHours", 
          "getUTCMilliseconds", 
          "getUTCMinutes", 
          "getUTCMonth", 
          "getUTCSeconds", 
          "getYear", 
          "setDate", 
          "setFullYear", 
          "setHours", 
          "setMilliseconds", 
          "setMinutes", 
          "setMonth", 
          "setSeconds", 
          "setTime", 
          "setUTCDate", 
          "setUTCFullYear", 
          "setUTCHours", 
          "setUTCMilliseconds", 
          "setUTCMinutes", 
          "setUTCMonth", 
          "setUTCSeconds", 
          "setYear", 
          "toDateString", 
          "toGMTString", 
          "toLocaleDateString", 
          "toLocaleFormat", 
          "toLocaleString", 
          "toLocaleTimeString", 
          "toSource", 
          "toString", 
          "toTimeString", 
          "toUTCString", 
          "valueOf" 
        ], 
        properties: [ 
          "constructor" 
        ] 
      }, 
      Error: { 
        methods: [ 
          "toSource", 
          "toString" 
        ], 
        properties: [ 
          "constructor", 
          "message", 
          "name", 
          "description", 
          "number", 
          "fileName", 
          "lineNumber", 
          "stack" 
        ] 
      }, 
      EvalError: { 
        methods: [ 
          "toSource", 
          "toString" 
        ], 
        properties: [ 
          "constructor", 
          "name" 
        ] 
      }, 
      Function: { 
        methods: [ 
          "apply", 
          "call", 
          "toSource", 
          "toString" 
        ], 
        properties: [ 
          "arity", 
          "caller", 
          "constructor", 
          "length", 
          "name" 
        ] 
      }, 
      Number: { 
        methods: [ 
          "toExponential", 
          "toFixed", 
          "toLocaleString", 
          "toPrecision", 
          "toSource", 
          "toString", 
          "valueOf" 
        ], 
        properties: [ 
          "constructor" 
        ] 
      }, 
      Object: { 
        methods: [ 
          "__defineGetter__", 
          "__defineSetter__", 
          "eval", 
          "hasOwnProperty", 
          "isPrototypeOf", 
          "__lookupGetter__", 
          "__lookupSetter__", 
          "__noSuchMethod__", 
          "propertyIsEnumerable", 
          "toSource", 
          "toLocaleString", 
          "toString", 
          "unwatch", 
          "valueOf", 
          "watch" 
        ], 
        properties: [ 
          "constructor", 
          "__parent__", 
          "__proto__" 
        ] 
      }, 
      RangeError: { 
        methods: [ 
          "toSource", 
          "toString" 
        ], 
        properties: [ 
          "constructor", 
          "name" 
        ] 
      }, 
      ReferenceError: { 
        methods: [ 
          "toSource", 
          "toString" 
        ], 
        properties: [ 
          "constructor", 
          "name" 
        ] 
      }, 
      RegExp: { 
        methods: [ 
          "exec", 
          "test", 
          "toSource", 
          "toString" 
        ], 
        properties: [ 
          "constructor", 
          "global", 
          "ignoreCase", 
          "lastIndex", 
          "multiline", 
          "source" 
        ] 
      }, 
      String: { 
        methods: [ 
          "charAt", 
          "charCodeAt", 
          "concat", 
          "indexOf", 
          "lastIndexOf", 
          "localeCompare", 
          "match", 
          "quote", 
          "replace", 
          "search", 
          "slice", 
          "split", 
          "substr", 
          "substring", 
          "toLocaleLowerCase", 
          "toLocaleUpperCase", 
          "toLowerCase", 
          "toSource", 
          "toString", 
          "toUpperCase", 
          "trim", 
          "trimLeft", 
          "trimRight", 
          "valueOf", 
          "anchor", 
          "big", 
          "blink", 
          "bold", 
          "fixed", 
          "fontcolor", 
          "fontsize", 
          "italics", 
          "link", 
          "small", 
          "strike", 
          "sub", 
          "sup" 
        ], 
        properties: [ 
          "constructor", 
          "length" 
        ] 
      }, 
      SyntaxError: { 
        methods: [ 
          "toSource", 
          "toString" 
        ], 
        properties: [ 
          "constructor", 
          "name" 
        ] 
      }, 
      TypeError: { 
        methods: [ 
          "toSource", 
          "toString" 
        ], 
        properties: [ 
          "constructor", 
          "name" 
        ] 
      }, 
      URIError: { 
        methods: [ 
          "toSource", 
          "toString" 
        ], 
        properties: [ 
          "constructor", 
          "name" 
        ] 
      } 
    }; 
    var prefix; 
    if(string.toLower(page.language) == 'he' || page.language == '') { 
      prefix = '/he/JavaScript/תיעוד_JavaScript/אובייקטים_גלובליים/'; 
    } 
    var captiontext = hedict[string.toLower($1)] + ' מ'; 
    var pageuri = wiki.uri(prefix + $0); 
    var htmlstring; 
    htmlstring = '' + captiontext + 
                     ' ' + $0 + 
                     ':
    '; web.html(htmlstring); var desiredprototype = prototypes[$0][string.toLower($1)]; var override=$2; var index = list.indexOf(desiredprototype, override); if (index != (-1)) { desiredprototype = list.splice(desiredprototype, index, 1); } htmlstring = ''; var lastindex = #desiredprototype - 1; var i = 0; foreach (var p in desiredprototype) { var pimproper = string.toUpperFirst(string.replace(p, '__', '')); pageuri = wiki.uri(prefix + $0 + '/' + pimproper); htmlstring += '' + p + ''; if (i != lastindex) { htmlstring += ', '; } i = i + 1; } htmlstring += ''; web.html(htmlstring);

    מתודות

    For methods available on Boolean instances, see Methods of Boolean instances.

    האובייקט Boolean אינו מכיל מתודות למעט אלו שהוא יורש.

     
    /** 
     * Replaces Template:JSInherits. Given an object and a list of properties or 
     * methods implemented elsewhere, output a list of the properties or methods 
     * inherited from that object. 
     * 
     * TODO: make it work with an inheritance chain, e.g., if you want inherited 
     * properties or methods from both Function and Object, where Function itself 
     * overrides methods from Object. We don't want to see that it inherits a 
     * "valueOf" method from Function and again on Object. 
     * 
     * @param the object to inherit from 
     * @param "properties" or "methods" 
     * @param a list of properties or methods overridden by this object 
     */ 
    var hedict = { 
    properties : 'מאפיינים היורשים', 
    methods: 'מתודות היורשות' 
    }; 
    var prototypes = { 
      Array: { 
        methods: [ 
          "pop", 
          "push", 
          "reverse", 
          "shift", 
          "sort", 
          "splice", 
          "unshift", 
          "concat", 
          "join", 
          "slice", 
          "toSource", 
          "toString", 
          "indexOf", 
          "lastIndexOf", 
          "filter", 
          "forEach", 
          "every", 
          "map", 
          "some", 
          "reduce", 
          "reduceRight" 
        ], 
        properties: [ 
          "constructor", 
          "index", 
          "input", 
          "length" 
        ] 
      }, 
      Boolean: { 
        methods: [ 
          "toSource", 
          "toString", 
          "valueOf" 
        ], 
        properties: [ 
          "constructor" 
        ] 
      }, 
      Date: { 
        methods: [ 
          "getDate", 
          "getDay", 
          "getFullYear", 
          "getHours", 
          "getMilliseconds", 
          "getMinutes", 
          "getMonth", 
          "getSeconds", 
          "getTime", 
          "getTimezoneOffset", 
          "getUTCDate", 
          "getUTCDay", 
          "getUTCFullYear", 
          "getUTCHours", 
          "getUTCMilliseconds", 
          "getUTCMinutes", 
          "getUTCMonth", 
          "getUTCSeconds", 
          "getYear", 
          "setDate", 
          "setFullYear", 
          "setHours", 
          "setMilliseconds", 
          "setMinutes", 
          "setMonth", 
          "setSeconds", 
          "setTime", 
          "setUTCDate", 
          "setUTCFullYear", 
          "setUTCHours", 
          "setUTCMilliseconds", 
          "setUTCMinutes", 
          "setUTCMonth", 
          "setUTCSeconds", 
          "setYear", 
          "toDateString", 
          "toGMTString", 
          "toLocaleDateString", 
          "toLocaleFormat", 
          "toLocaleString", 
          "toLocaleTimeString", 
          "toSource", 
          "toString", 
          "toTimeString", 
          "toUTCString", 
          "valueOf" 
        ], 
        properties: [ 
          "constructor" 
        ] 
      }, 
      Error: { 
        methods: [ 
          "toSource", 
          "toString" 
        ], 
        properties: [ 
          "constructor", 
          "message", 
          "name", 
          "description", 
          "number", 
          "fileName", 
          "lineNumber", 
          "stack" 
        ] 
      }, 
      EvalError: { 
        methods: [ 
          "toSource", 
          "toString" 
        ], 
        properties: [ 
          "constructor", 
          "name" 
        ] 
      }, 
      Function: { 
        methods: [ 
          "apply", 
          "call", 
          "toSource", 
          "toString" 
        ], 
        properties: [ 
          "arity", 
          "caller", 
          "constructor", 
          "length", 
          "name" 
        ] 
      }, 
      Number: { 
        methods: [ 
          "toExponential", 
          "toFixed", 
          "toLocaleString", 
          "toPrecision", 
          "toSource", 
          "toString", 
          "valueOf" 
        ], 
        properties: [ 
          "constructor" 
        ] 
      }, 
      Object: { 
        methods: [ 
          "__defineGetter__", 
          "__defineSetter__", 
          "eval", 
          "hasOwnProperty", 
          "isPrototypeOf", 
          "__lookupGetter__", 
          "__lookupSetter__", 
          "__noSuchMethod__", 
          "propertyIsEnumerable", 
          "toSource", 
          "toLocaleString", 
          "toString", 
          "unwatch", 
          "valueOf", 
          "watch" 
        ], 
        properties: [ 
          "constructor", 
          "__parent__", 
          "__proto__" 
        ] 
      }, 
      RangeError: { 
        methods: [ 
          "toSource", 
          "toString" 
        ], 
        properties: [ 
          "constructor", 
          "name" 
        ] 
      }, 
      ReferenceError: { 
        methods: [ 
          "toSource", 
          "toString" 
        ], 
        properties: [ 
          "constructor", 
          "name" 
        ] 
      }, 
      RegExp: { 
        methods: [ 
          "exec", 
          "test", 
          "toSource", 
          "toString" 
        ], 
        properties: [ 
          "constructor", 
          "global", 
          "ignoreCase", 
          "lastIndex", 
          "multiline", 
          "source" 
        ] 
      }, 
      String: { 
        methods: [ 
          "charAt", 
          "charCodeAt", 
          "concat", 
          "indexOf", 
          "lastIndexOf", 
          "localeCompare", 
          "match", 
          "quote", 
          "replace", 
          "search", 
          "slice", 
          "split", 
          "substr", 
          "substring", 
          "toLocaleLowerCase", 
          "toLocaleUpperCase", 
          "toLowerCase", 
          "toSource", 
          "toString", 
          "toUpperCase", 
          "trim", 
          "trimLeft", 
          "trimRight", 
          "valueOf", 
          "anchor", 
          "big", 
          "blink", 
          "bold", 
          "fixed", 
          "fontcolor", 
          "fontsize", 
          "italics", 
          "link", 
          "small", 
          "strike", 
          "sub", 
          "sup" 
        ], 
        properties: [ 
          "constructor", 
          "length" 
        ] 
      }, 
      SyntaxError: { 
        methods: [ 
          "toSource", 
          "toString" 
        ], 
        properties: [ 
          "constructor", 
          "name" 
        ] 
      }, 
      TypeError: { 
        methods: [ 
          "toSource", 
          "toString" 
        ], 
        properties: [ 
          "constructor", 
          "name" 
        ] 
      }, 
      URIError: { 
        methods: [ 
          "toSource", 
          "toString" 
        ], 
        properties: [ 
          "constructor", 
          "name" 
        ] 
      } 
    }; 
    var prefix; 
    if(string.toLower(page.language) == 'he' || page.language == '') { 
      prefix = '/he/JavaScript/תיעוד_JavaScript/אובייקטים_גלובליים/'; 
    } 
    var captiontext = hedict[string.toLower($1)] + ' מ'; 
    var pageuri = wiki.uri(prefix + $0); 
    var htmlstring; 
    htmlstring = '' + captiontext + 
                     ' ' + $0 + 
                     ':
    '; web.html(htmlstring); var desiredprototype = prototypes[$0][string.toLower($1)]; var override=$2; var index = list.indexOf(desiredprototype, override); if (index != (-1)) { desiredprototype = list.splice(desiredprototype, index, 1); } htmlstring = ''; var lastindex = #desiredprototype - 1; var i = 0; foreach (var p in desiredprototype) { var pimproper = string.toUpperFirst(string.replace(p, '__', '')); pageuri = wiki.uri(prefix + $0 + '/' + pimproper); htmlstring += '' + p + ''; if (i != lastindex) { htmlstring += ', '; } i = i + 1; } htmlstring += ''; web.html(htmlstring);

    מופעי Boolean

    כל המופעים של Boolean יורשים מ Boolean.prototype.

    מאפיינים

    מתודות

    דוגמאות

    יצירת אובייקט Boolean עם false כערך התחלתי

    bNoParam = new Boolean();
    bZero = new Boolean(0);
    bNull = new Boolean(null);
    bEmptyString = new Boolean("");
    bfalse = new Boolean(false);
    

    יצירת אובייקט Boolean עם true כערך התחלתי

    btrue = new Boolean(true);
    btrueString = new Boolean("true");
    bfalseString = new Boolean("false");
    bSuLin = new Boolean("Su Lin");
    

    ראו גם

     

    Document Tags and Contributors

    Contributors to this page: ziv, teoli
    Last updated by: teoli,