es6

Displaying 1 - 5 of 5

Scala vs Javascript (ES6, TypeScript, Node.js)

Now with Scala.js allowing isomorphic Scala code to run on both browser and server. Scala contends with JavaScript in the web domain. But assuming we are talking about web, how do the two languages compare?

First, JavaScript comes in a few flavors. There's ES5 which is currently running in all browsers. There's Node.js, which is the same Google V8 JavaScript engine but running outside the browser and thus without browser/web apis included, but which can run ES6 (EcmaScript 6). And then there are the many languages that compile or transpile down to plain old ES5 JavaScript,...

Python-like List Comprehensions in JavaScript

Python has a neat syntactic feature where you can take a literal list constructor's bracket notation (e.g. [2, 4, 6, 8, 10]) but have code statements generate the list's contents. So instead of writing out the 5 even numbers in the example, one could write [(x+1)*2 for x in range(5)] which turns out to be more characters but you can imagine the savings if the series in the list was longer. Instead of range() we could have a literal list [0, 1, 2, 3, 4] or even a generator function, anything which is iterable.

How could we do this...

Creating forms with callbacks in React+Redux

In React, you have some simple/dumb components which are just html and other components and maybe render some values which are passed in. It becomes a little trickier when you want to add some functionality to the component, such as form elements - inputs and buttons and submit actions. What I mean by "forms with callbacks" is that you want to execute some JavaScript and also change state in your React app, but do so without giving direct access to state to the component. Instead here's one way to do it.

  1. Draw out the HTML (don't worry about using React components yet) in JSX
  2. ...

Quick explanation of JavaScript Promises

"JavaScript Promises: reason about async events, serially chain them, reduce them. General replacement for XHR"

What is a promise? Conceptually and outside the context of code, a promise is either a willful intention of achieving a result or a promise is considered the actual result itself. EcmaScript 6 (ES6) introduces the Promises API which is currently implemented by most browsers (and Edge but not IE according to caniuse.com - but there's a polyfill for that). So a JavaScript Promise is simply an object of some callback...

JavaScript's Symbol Type (ECMAScript 6)

JavaScript is not a strongly-typed language like many classic compiled languages. Instead, like many scripting languages, it is loosely typed and has just a few basic types: number, string, object, boolean. There are also two types which are used as values (rather than to hold varying values like numbers and strings) which are null (no value) and undefined (the initial or undefined value of a variable). JavaScript is aware of Arrays as a type of object, but is still an object and not a separate type. Objects in JavaScript take prototypical inheritence. A literal object looks like a Python...

es6 | TECH.SAIGONIST.COM

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /home/tomo/web/tech.saigonist.com/drupal7/php/includes/common.inc:2776) in drupal_send_headers() (line 1486 of /home/tomo/web/tech.saigonist.com/drupal7/php/includes/bootstrap.inc).
  • Error: Class 'CToolsCssCache' not found in _cache_get_object() (line 32 of /home/tomo/web/tech.saigonist.com/drupal7/php/includes/cache.inc).
The website encountered an unexpected error. Please try again later.