To fix what ain't broke!
console.ident =
v => ( console.log( v ), v );
v => v;
Expressive
languageBinaryExpression:
1+1
AssignmentExpression:
x = 1 + 1
ArrowFunctionExpression:
v => v + 1
CallExpression:
[1, 2].map( v => v + 1 )
Async:
callbacks;
`Promise`, `async`;
Iterate:
for( var ... ){ ... }
`map`, `filter`, `reduce`;
Conditional:
if ( bool ) ... else …
`bool ? a : b`;
Function:
function ( v ) {…}
`v => v`;
const userID = getUserId(
JSON.parse( localStorage.getItem( 'user' ) )
);
// Uncaught SyntaxError: Unexpected token o in JSON at position 1
const userStr = localStorage.getItem( 'user' )
console.log( userStr )
// "[ object Object ]"
const userID = getUserId(
JSON.parse( userStr )
);
// Uncaught SyntaxError: Unexpected token o in JSON at position 1
Number( val ) ? formatCurrency( str ) : val;
// 0
console.log( val, Number( val ), !!Number( val ) );
// 0 0 false
Number( val ) ? formatCurrency( str ) : val;
// 0
const pickAndFormatTransaction = ( {
description,
date,
amount,
...details
} ) => ( {
description,
date: moment( date ).format( 'DD/MM/YYY ' ),
amount: Number( val ) ? formatCurrency( str ) : val,
details
} );
console.ident =
v => ( console.log( v ), v );
const userStr = localStorage.getItem( 'user' )
console.log( userStr )
// "[object Object]"
const userID = getUserId(
JSON.parse( userStr )
);
// Uncaught SyntaxError: Unexpected token o in JSON at position 1
const user = JSON.parse(
console.ident( localStorage.getItem( 'user' ) )
);
console.log( val, Number( val ), !!Number( val ) );
// 0 0 false
Number( val ) ? formatCurrency( str ) : val;
// 0
console.ident( Number( console.ident( val ) ) )
? formatCurrency( str )
: val;
const pickAndFormatTransaction = ( {
description,
date,
amount,
...details
} ) =>
console.ident( {
description,
date: moment( console.ident( date )).format( 'DD/MM/YYY ' ),
amount: console.ident( Number( val ))
? formatCurrency( str )
: val
} );
const result = console
.ident( arr.map( parseNumber s ).filter( removeOdds ) )
.reduce( average );
console.ident =
v => ( console.log( v ), v );
Have Fun!