17 private links
You can simply save and restore the entire events object:
var events=$._data(elem, 'events'); // save events
$._data(elem, 'events', {}); // cancel all events
// any code here will not fire events
$._data(elem, 'events', events); // restore events
This worked for me but may have unknown side effects ...
Day.js is a minimalist JavaScript library that parses, validates, manipulates, and displays dates and times for modern browsers with a largely Moment.js-compatible API. If you use Moment.js, you already know how to use Day.js.
A free, once–weekly email roundup of JavaScript news and articles.
We help developers, and the companies they work for, stay up-to-date via our variety of publications, across the web, social and by email.
This is an extract from chapter 11 of Ashley Davis’s book Data Wrangling with JavaScript now available on the Manning Early Access Program. I absolutely
It’s been for an hour or two now since I woke up, and I’m still sitting on my bed because my floor is full of bugs. Yes, bugs.. and no, I…
const result = _.map({a: 1, b: 2}, function(value, key) {
return value + key;
});
Since nobody has added the obvious solution yet which works fine for two comparisons, I'll offer it:
if (foobar == foo || foobar == bar) {
//do something
}
And, if you have lots of values, then I'd suggest making a Set as this makes very clean and simple comparison code and it's fast at runtime:
// pre-construct the Set
var tSet = new Set([foo, bar, test1, test2, test3]);
// test the Set at runtime
if (tSet.has(foobar)) {
// do something
}
For pre-ES6, you can get a Set polyfill of which there are many. One is described in this other answer.
This lightweight tool helps you get a sense of your application's schema, as well as any outliers to that schema. Particularly useful when you inherit a codebase with data dump and want to quickly learn how the data's structured. Also useful for finding rare keys.
$ mongo test --eval "var collection = 'users'" variety.js
+------------------------------------------------------------------+
| key | types | occurrences | percents |
| ------------------ | ------------ | ----------- | -------- |
| _id | ObjectId | 5 | 100.0 |
| name | String | 5 | 100.0 |
| bio | String | 3 | 60.0 |
| birthday | Date | 2 | 40.0 |
| pets | Array(1),String(1) | 2 | 40.0 |
| someBinData | BinData-old | 1 | 20.0 |
| someWeirdLegacyKey | String | 1 | 20.0 |
+------------------------------------------------------------------+
Aggregation is a very small JavaScript library for Node.js environments, providing just a single function, for use in ECMAScript 5/6 class inheritance based on mixins. It aggregates a base class and one or more mixin classes into an aggregate class, which then is usually subsequently used as the base class for another class.
mics (pronounce: mix) is a library that makes multiple inheritance in Javascript a breeze. Inspired by the excellent blog post “Real” Mixins with Javascript Classes by Justin Fagnani, mics tries to build a minimal library around the concept of using class expressions (factories) as mixins. mics extends the concepts presented in the blog post by making the mixins first-class citizens that can be directly used to instantiate objects and can be mixed in with other mixins instead of just with classes.
The truth is, ternaries are usually much simpler than if statements. People believe the reverse for two reasons:
- They’re more familiar with if statements. Familiarity bias can lead us to believe things that aren’t true, even when we’re presented with evidence to the contrary.
- People try to use ternary statements as if they’re if statements. That doesn’t work, because ternary expressions are expressions, not statements.
Before we get into the details, let’s define a ternary expression:
A ternary expression is a conditional expression that evaluates to a value. It consists of a conditional, a truthy clause (the value to produce if the conditional evaluates to a truthy value), and a falsy clause (the value to produce if the conditional evaluates to a falsy value).
Extension for Visual Studio Code - Sublime Text's babel-sublime grammar in VS Code.
A quick overview of new JavaScript features in ES2015, ES2016, ES2017 and beyond.
The (many) reasons why you could not have JS.
Free yourself from the chains of jQuery by embracing and understanding the modern Web API and discovering various directed libraries to help you fill in the gaps.
Closer to the Metal
Preact provides the thinnest possible Virtual DOM abstraction on top of the DOM. The web is a stable platform, it's time we stopped reimplementing it in the name of safety.
Preact is also a first-class citizen of the web platform. It diffs Virtual DOM against the DOM itself, registers real event handlers, and plays nicely with other libraries.
Small Size
Most UI frameworks are large enough to be the majority of an app's JavaScript size. Preact is different: it's small enough that your code is the largest part of your application.
That means less JavaScript to download, parse and execute - leaving more time for your code, so you can build an experience you define without fighting to keep a framework under control.
Big Performance
Preact is fast, and not just because of its size. It's one of the fastest Virtual DOM libraries out there, thanks to a simple and predictable diff implementation.
It even includes extra performance features like customizable update batching, optional async rendering, DOM recycling, and optimized event handling via Linked State.
Portable & Embeddable
Preact's tiny footprint means you can take the powerful Virtual DOM Component paradigm to new places it couldn't otherwise go.
Use Preact to build parts of an app without complex integration. Embed Preact into a widget and apply the same tools and techniques that you would to build a full app.
Instantly Productive
Lightweight is a lot more fun when you don't have to sacrifice productivity to get there. Preact gets you productive right away. It even has a few bonus features:
- props, state and context are passed to render()
- Use standard HTML attributes like class and for
- Works with React DevTools right out of the box
Ecosystem Compatible
Virtual DOM Components make it easy to share reusable things - everything from buttons to data providers. Preact's design means you can seamlessly use thousands of Components available in the React ecosystem.
Adding a simple preact-compat alias to your bundler provides a compatibility layer that enables even the most complex React components to be used in your application.
The built-in js-mode in Emacs does not provide many features for working with js framework beside js editing and syntax highlighting. The tips in this post will help you transform your Emacs into a powerful Javascript IDE.