This is an old post. Information here may be out-dated, or the post may re¬≠Ô¨āect opin¬≠ions or be¬≠liefs I no longer share.

JavaScript is a wel­com­ing lan­guage - ad­mit­tedly, one that takes much longer to mas­ter than it does to learn.

At work, I’ve been work­ing on in­ter­est­ing bits and pieces which are help­ing me so­lid­ify my knowl­edge. Here are some in­ter­est­ing as well as mun­dane things I’ve got­ten com­fort­able with re­cently.

win­dow.print() is not a part of ECMAScript

Documentation

I was sur­prised to learn that window.print() is not a spec - only a Living Standard. From a cur­sory test, it seems Firefox for Android does not know what to do with window.print() whereas Chrome for Android does. If you wrap your web­site in an Android WebView or UIWebView/WKWebView, nei­ther Android nor iOS will get you any­where with a call to this func­tion.

Android’s de­vel­oper doc­u­men­ta­tion specif­i­cally states:

You cannot use JavaScript in a HTML document to trigger printing.

Object spread syn¬≠tax to write Ô¨āex¬≠i¬≠ble con¬≠struc¬≠tors and meth¬≠ods

Documentation

Consider:

const createShape = (config) => {
return {
length: 50,
breadth: 30,
{...config}
};
};

let sqauare = createShape({ breadth: 50 });
let cube = createShape({ height: 75 });

You can add ad­di­tional key-value pairs, or over­rwrite an ex­ist­ing pair, or both!

It was a tweet by @wesbos that re¬≠ally so¬≠lid¬≠i¬≠Ô¨Āed it as a pat¬≠tern in my mem¬≠ory, de¬≠spite hav¬≠ing used it at work sev¬≠eral times.

Your browser can Ô¨Ānd out a lot about your bat¬≠tery

Your browser lets any­one query what the sta­tus and charge level of your bat­tery is. How cool and fright­en­ing is that?

JavaScript Navigator's getBattery

An in­ter­est­ing Atom key­board short­cut

I love key­board short­cuts - eas­ing them into your men­tal map and mus­cle mem­ory is a huge plus to your day-to-day pro­duc­tiv­ity, with­out the stress of re­mem­ber­ing 20 key­board com­bi­na­tions all at once.

I chanced upon Ctrl + R which gen¬≠er¬≠ates sym¬≠bols and lets you look through or search just the meth¬≠ods in a Ô¨Āle. This is what it looks like in a React Ô¨Āle us¬≠ing ES6 classes:

Atom keyboard shortcut preview