>>Did ES5 make it valid or was it valid in ES3? The short answer is that it's always been valid.
The long answer: A propertyName is simply a sequence of characters that refers to the property of an object, and has fewer rules around what is valid, than an identifier sequence. The way in which that property is accessed, via those sequence of characters is what matters. If a property is always accessed via bracket-notation, then you needn't really worry about what sequence of characters composes the propertyName. If you are using dot-notation then, unfortunately, you are utilizing "identifier" syntax to access the property of the object. There are a few things that have to follow "identifier" syntax in JavaScript, a variable declaration, a function declaration, and the dot-notation (I don't think there are others, but I may be mistaken). Theoretically, though not realistically, you could refactor most JS code to avoid identifiers altogether. You could use bracket-notation to create anything (ie variable replacement) you needed, and you could avoid function declarations, etc. For more reading on bracket-notation, and propertyNames syntax see section 11.5-11.6 of ECMA-262 3rd edition, for more on identifier syntax see 7.5-7.6 ibid. On Sat, Aug 27, 2011 at 12:53 PM, Xavier MONTILLET <[email protected]>wrote: > But it looses all the interest of having a nice name for your method. > > Sent from my smartphone. > On Aug 27, 2011 9:50 PM, "Nathan Sweet" <[email protected]> wrote: > >>>Does work in all implementations? > > Although, > > o['delete'] = true; > > is perfectly valid, and will work in all browsers. > > > > On Sat, Aug 27, 2011 at 12:49 PM, Nathan Sweet <[email protected] > >wrote: > > > >> >>Does work in all implementations? > >> Sorry, Peter's right, it is invalid, but the point still stands about > the > >> nature of JSLint. > >> > >> On Sat, Aug 27, 2011 at 12:48 PM, Nathan Sweet <[email protected] > >wrote: > >> > >>> >>And why do jslint and jshint cry? Just a bug? > >>> JS lint is quite opinionated, and wants to direct you towards best > >>> practices. JSLint will tell you not to do things that are perfectly > valid. > >>> This general opinionated nature is a good thing, because it will, > overall, > >>> make you a better JavaScripter, but there are times when it can/should > be > >>> ignored. > >>> > >>> > >>> On Sat, Aug 27, 2011 at 12:24 PM, Xavier MONTILLET < > >>> [email protected]> wrote: > >>> > >>>> Does work in all implementations? > >>>> > >>>> And why do jslint and jshint cry? Just a bug? > >>>> > >>>> Sent from my smartphone. > >>>> On Aug 27, 2011 9:20 PM, "Peter van der Zee" <[email protected]> > wrote: > >>>> > On Sat, Aug 27, 2011 at 9:05 PM, xavierm02 <[email protected] > > > >>>> wrote: > >>>> >> Hi, > >>>> >> I was wondering when it was allowed to use reserved words. Let's > say > >>>> > > >>>> > You can use reserved words as property names of objects. You cannot > >>>> > use them as variable names. Note that the property names of the > object > >>>> > literal are not "variables". So in your example: > >>>> > > >>>> > var o = { > >>>> > delete: true > >>>> > }; > >>>> > > >>>> > `o` is a variable and `delete` is a property name. > >>>> > > >>>> > - peter > >>>> > > >>>> > -- > >>>> > To view archived discussions from the original JSMentors Mailman > list: > >>>> http://www.mail-archive.com/[email protected]/ > >>>> > > >>>> > To search via a non-Google archive, visit here: > >>>> http://www.mail-archive.com/[email protected]/ > >>>> > > >>>> > To unsubscribe from this group, send email to > >>>> > [email protected] > >>>> > >>>> -- > >>>> To view archived discussions from the original JSMentors Mailman list: > >>>> http://www.mail-archive.com/[email protected]/ > >>>> > >>>> To search via a non-Google archive, visit here: > >>>> http://www.mail-archive.com/[email protected]/ > >>>> > >>>> To unsubscribe from this group, send email to > >>>> [email protected] > >>>> > >>> > >>> > >> > > > > -- > > To view archived discussions from the original JSMentors Mailman list: > http://www.mail-archive.com/[email protected]/ > > > > To search via a non-Google archive, visit here: > http://www.mail-archive.com/[email protected]/ > > > > To unsubscribe from this group, send email to > > [email protected] > > -- > To view archived discussions from the original JSMentors Mailman list: > http://www.mail-archive.com/[email protected]/ > > To search via a non-Google archive, visit here: > http://www.mail-archive.com/[email protected]/ > > To unsubscribe from this group, send email to > [email protected] > -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
