Many of the functions for general operations are distributed across a bunch of objects and keywords in JavaScript. This increases the cognitive load and increases the number of times a language operation needs to be looked up. Here are a few quick examples:
const obj = { property1: 'value1', property2: 'value2', }; delete obj.property1; Object.preventExtensions(obj); try { obj.property3 = 'value3' } catch(e) { console.log(e.message); } console.log(obj); // { property2: 'value2' }
Reflect simplifies this by providing a consistent API for all of the operations:
const obj2 = { property1: 'value1', property2: 'value2', }; Reflect.deleteProperty(obj2, 'property1'); Reflect.preventExtensions(obj2); const succeeded = Reflect.set(obj2, 'property3', 'value3'); if (succeeded !== true) { console.log('Failed to set "property3", obj is not extensible'); } console.log(obj2); // { property2: 'value2' }
Notice how Reflect.set does not return an error and returns if the value was set instead. Even for basic operations, reflect can help clarify the code more
Those were just a few examples, you can view the full list here. Since Reflect provides a consistent API for many operations, it should generally be used instead of all the separate interfaces when it is available. There are exceptions when the syntax is more clear though; except for cases like the above, setting variables with obj.a = 'value' is usually clearer than Reflect.set(obj, 'a', 'value'). It is supported in all browsers including MS Edge, but not IE 11.
Github Location: https://github.com/Jacob-Friesen/obscurejs/blob/master/2017/reflect.js
Top 10 Cool Gadgets You Can Buy Now On Amazon
Working on it.
The United States is paradoxically home to some of the world’s biggest tech companies and yet doesn’t have enough people studying computer science to fill those jobs.
The U.S. will have 1 million open computing jobs by 2024, according to a recent report by the App Association.
In 2013, the Obama Administration issued a similar statistic estimating that there would be 1.4 million computer science jobs even sooner — by 2020 — but fewer than 400,000 people will graduate with the right skills to fill them. Read more (7/21/17)
follow @the-future-now
Exclusive Rae Sremmurd from Lollapalooza…
via Drew Levin
most of y’all have seen the new cursive font, but there’s actually three new fonts available for regular text posts. I’m gonna tell you how to use them on the desktop site and how to add them to your Tumblr theme.
1. Fairwater (Quirky)
click the gear in the top-right of posts and select “HTML” from “Text editor”. Then just type <p class=“npf_quirky”>Hello!</p> and replace the text with whatever you want.
to put it in your Tumblr theme, go to your customize page > Advanced options > ADD CUSTOM CSS and paste this code:
p.npf_quirky { font-family: Fairwater, serif; font-size: 24px; line-height: 1.3em; } @font-face{font-family:Fairwater; src:url("http://static.tumblr.com/zgb0z1w/eKLov1ol9/fairwater_script_regular-webfont.woff2?v=b7ab7a58cded3365889a447bfd9e9c45") format("woff2"),url("http://static.tumblr.com/zgb0z1w/Ia8ov1pxd/fairwater_script_regular-webfont.woff?v=96e975b7468359e6f67086305577e43e") format("woff"); font-weight:400; font-style:normal}
2. Calluna (Quote)
click the gear in the top-right of posts and select “HTML” from “Text editor”. Then just type <p class=“npf_quote”>Hello!</p> and replace the text with whatever you want.
to put it in your Tumblr theme, go to your customize page > Advanced options > ADD CUSTOM CSS and paste this code:
p.npf_quote { font-family: Calluna, sans-serif; font-size: 14px; } @font-face{font-family:Calluna; src:url("http://static.tumblr.com/zgb0z1w/Pjnov1py3/calluna-regular-webfont.eot?3=&v=7c192d86344b943cd3e8d9123ed1dafa");src:url("http://static.tumblr.com/zgb0z1w/Pjnov1py3/calluna-regular-webfont.eot?3%3F=&v=7c192d86344b943cd3e8d9123ed1dafa#iefix") format("embedded-opentype"),url("http://static.tumblr.com/zgb0z1w/ALjov1pzw/calluna-regular-webfont.woff?3=&v=60172bcdc91d310108023e102eec8676") format("woff"),url("http://static.tumblr.com/zgb0z1w/HsIov1q0g/calluna-regular-webfont.ttf?3=&v=cc6292d625d03dc65b9665f0cd27e2cd") format("truetype"); font-weight:400; font-style:normal}
3. Courier (Chat)
click the gear in the top-right of posts and select “HTML” from “Text editor”. Then just type <p class=“npf_chat”>Hello!</p> and replace the text with whatever you want.
to put it in your Tumblr theme, go to your customize page > Advanced options > ADD CUSTOM CSS and paste this code:
p.npf_chat { font-family: Courier, monospace; font-size: 14px; }
have fun with the new fonts!
someone take Gorn away from him before he loses his mind
Meme of the day.
Thank you to @djmakproto for the source link, which I could not previously find!
The Vesta Explorer in Strange New World (USA, 1975 dir: Robert Butler).
Check it out: https://pennweallotu1975.tumblr.com/post/164528177008/fiber-optic-hoodie-lazyop