Take the 2-minute tour ×

I am trying to learn JavaScript, but my English is not that good.

While reading Simply JavaScript by Kevin Yank & Cameron Adams, I came across this paragraph, and I want to know what one sentence in it means:

Thanks to the wide adoption of the Document Object Model (DOM) standard, accessing HTML elements in your JavaScript code works very similarly in every browser. If only the same could be said for every aspect of JavaScript! As it happens, running JavaScript code in response to an event stands out as one of the few remaining features that are implemented in wildly varying ways in current browsers.

What does "If only the same could be said for every aspect of JavaScript!" mean?

share|improve this question

1 Answer 1

Starting a sentence with "If only" indicates that one wishes the proceeding statement were true. That is, it would be nice if the statement made reflected reality.

For example:

If only everyone laughed at my jokes!


If only my love and I could be together!

So the person making this statement must have expressed some opinion about a certain aspect of JavaScript--e.g., JavaScript's mechanism for accessing DOM elements is consistent across major browsers--and then expressed the opinion, through the statement you've quoted, that this characteristic (cross-browser consistency) unfortunately does not hold for some other aspects of the language.

share|improve this answer
actually sometimes it is much more than "it would be nice"; the phrase can be used for things that are crucial. –  Unreason Jul 25 '11 at 7:59
You might also note that in "the same could be said", "the same" refers to something mentioned usually just previously. For example, if I say "Dan's writing is good. The same could be said about aedia's", I mean that aedia's writing is also good. But, "Dan's writing is good. If only the same could be said about aedia's!" means it is not true that aedia's writing is good, but I wish it were :) –  aedia λ Jul 25 '11 at 15:30

Your Answer


