简体   繁体   中英

window[“name”] and window.name in javascript

I'm a beginner of javascript. Here is my question.

Is there any difference between window["property_name"] and window.property_name in javascript?

These forms are identical when name is a valid JavaScript identifier ; in this case the property name is "name" .

The form with braces is required when the property name is an arbitrary expression ( obj[propNameVariable] ) or the property name is not a valid identifier ( obj["invalid identifier"] ).

All property names in JavaScript are internally strings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM