Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

OP can save a few more characters by not using 'var' and using 'E' notation for representing 15000, i.e, 15E3, or better, 2E4.


He can save 14 more if instead of creating a function he copies the function content inside of 'onclick'. And he can save one by using +new Date instead of Date.now().


Better yet, set a variable to Date.now since it's called twice.


It's called at different times so will return different values, which is important.


They meant something like "var n = Date.now".

However, there is no guarantee that this will work since it assumes that `this` isn't used by that function.

E.g. if you want to do something like that with console.log or document.querySelector, you have to use bind:

  var log = console.log.bind(console);
  var qs = document.querySelector.bind(document);


a = Date.now; b = a(); c = a();


Could also use `!0` for `true`.


He could use the savings to close that <p> tag.


It isn't XHTML. Closing <p> tags are optional (which is true for many tags). You don't even need opening HTML, HEAD or BODY tags.


That's only true in very specific cases: https://developer.mozilla.org/en/docs/Web/HTML/Element/p

The start tag is mandatory. The end tag may be omitted if the <p> element is immediately followed by an <address>, <article>, <aside>, <blockquote>, <div>, <dl>, <fieldset>, <footer>, <form>, <h1>, <h2>, <h3>, <h4>, <h5>, <h6>, <header>, <hr>, <menu>, <nav>, <ol>, <pre>, <section>, <table>, <ul> or another <p> element, or if there is no more content in the parent element and the parent element is not an <a> element.


And "there is no more content in the parent element" applies here.

Actually, what you call "very specific cases" are in fact, well, all reasonable cases. That list consists of all block level elements that can appear in `body`, so the statement could be reworded, that "<p> cannot contain any block-level element, so any inline element after <p> falls in, any block level element ends opened <p>".

Funny fact is that presence of optional end tags means nearly nothing for HTML parsers used in current browsers, they just ignore them. Some border cases regarding white space exists, or at least existed in the past, but in general, if you feed browser with document

    <!doctype html><html><head><title>a</title></head><body><table><tbody><tr><td><p>b</p></td></tr></tbody></table></body></html>`
or

    <!doctype html><title>a</title><table><tr><td><p>b</table>`
makes absolutely no difference. Both will result in exactly same DOM tree, both are "100% valid W3C HTML documents".




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: