JSFiddle - React, Tailwind, and code Playground

by Hakan Bilgin

JavaScript

var func = function(str, opt) {
	var def = {
			color: 'red',
			font: 'arial'
		};

		opt = extend( def, opt || {} );

		console.log( opt );
	},
	extend = function(src, dest) {
		for (var content in dest) {
			if (!src[content] || typeof(dest[content]) !== 'object') {
				src[content] = dest[content];
			} else {
				extend(src[content], dest[content]);
			}
		}
		return src;
	};

func( 'hej' );
func( 'hej', {font: 'Tahoma'} );