If I do this
var element = {}; alert(element); element[name] = "stephen"; alert(element.name);
Why doesn’t work element.name?
element.name
When using a notation bracket (if it is not a variable), it should be in qoutes, for example:
var element = {}; alert(element); element["name"] = "stephen"; alert(element.name);
You cannot check it here . To explain what I mean by “if it's not a variable”, this would also work:
var myVariable = "name"; element[myVariable] = "stephen";
Because the name must be in quotation marks. It works:
var element = {}; alert(element); element['name'] = "stephen"; alert(element.name);
Give it a try.
. :
, . , .
obj[name].age // Here the name is a variable, and it can be changed in every page refresh, for example.
obj['name'] = 'Lorenzo', .
obj['name'] = 'Lorenzo'
, set obj[name], obj['name'] .
obj[name]
obj['name']
Source: https://habr.com/ru/post/1770782/More articles:База данных: имеет ли приложение "HX" значительную ценность? - sqlManagement library error: Failed to create "System.Type" from the text "local: SolidGloss" - silverlightВыберите первые 10 событий из wevtutil, используя xpath - xpathConnecting a real device to an Android emulator - android-emulatorarray of integers in x86 embedded assembly - assemblyStatic Confusion Method - c #Suddenly getting this svn error - command-lineAuthlogic, rails3_acts_as_paranoid and validates_uniqueness_of: login + default_scope (: conditions => {: active => true}) - scopeWCF: соединение сокета было прервано - c#SQL CLR DDL trigger written in C # - sql-serverAll Articles