by Ossi Hanhinen, @ohanhi
with the support of Futurice 💚.
Licensed under CC BY 4.0.
var myString = 'EXAMPLEstring'; | |
var myNewString = myString.replace(/[A-Z]/g, '0'); | |
console.log(myNewString); | |
function replaceFunc (a, b, c) { | |
console.log(a, b, c); | |
return a.toLowerCase(); | |
} | |
var myOtherString = myString.replace(/[A-Z]/g, replaceFunc); |
import { Component } from "React"; | |
export var Enhance = ComposedComponent => class extends Component { | |
constructor() { | |
this.state = { data: null }; | |
} | |
componentDidMount() { | |
this.setState({ data: 'Hello' }); | |
} | |
render() { |
'use strict'; | |
// simple express server | |
var express = require('express'); | |
var app = express(); | |
var router = express.Router(); | |
app.use(express.static('public')); | |
app.get('/', function(req, res) { | |
res.sendfile('./public/index.html'); |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
/* | |
* Natural Sort algorithm for Javascript - Version 0.7 - Released under MIT license | |
* Author: Jim Palmer (based on chunking idea from Dave Koelle) | |
* Reference: http://www.overset.com/2008/09/01/javascript-natural-sort-algorithm/ | |
*/ | |
function naturalSort (a, b) { | |
var re = /(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi, | |
sre = /(^[ ]*|[ ]*$)/g, | |
dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/, | |
hre = /^0x[0-9a-f]+$/i, |