.
) وتدوين قوس ( []
) ، شبيه بصفيف. Dot notation هو ما تستخدمه عندما تعرف اسم العقار الذي تحاول الوصول إليه في وقت مبكر. هنا عينة من استخدام تدوين النقطة ( .
) لقراءة خاصية الكائن: var myObj = {
prop1: "val1" ،
prop2: "val2"
}؛
var prop1val = myObj.prop1 ، // val1
var prop2val = myObj.prop2؛ // val2
testObj
باستخدام التدوين النقطي. تعيين hatValue
متغير يساوي hat
خاصية الكائن وتعيين shirtValue
متغير shirtValue
يساوي shirt
خاصية الكائن. hatValue
سلسلة
testString: 'assert(typeof hatValue === "string" , "hatValue
should be a string");'
- text: قيمة hatValue
يجب أن تكون "ballcap"
testString: 'assert(hatValue === "ballcap" , "The value of hatValue
should be "ballcap"
");'
- text: يجب أن يكون shirtValue
عبارة عن سلسلة
testString: 'assert(typeof shirtValue === "string" , "shirtValue
should be a string");'
- text: يجب أن تكون قيمة shirtValue
"jersey"
testString: 'assert(shirtValue === "jersey" , "The value of shirtValue
should be "jersey"
");'
- text: يجب عليك استخدام dot notation مرتين
testString: 'assert(code.match(/testObj\.\w+/g).length > 1, "You should use dot notation twice");'
```