console.log(true ? "its true": "its false")
// returns its true or its false
console.log(true && "its true")
// returns its true
console.log(false && "its true")
// returns Boolean false
console.log(true && "its true" && "its false")
// returns "its true"
console.log(false || "its false")
// returns "its false"
// You can also test some values
console.log(null || "false") // returns "false"
console.log(NaN || "its false") // returns "false"
console.log(undefined || "its false") // returns "false"
console.log('' || "its false") // returns "false"
import { observable, action, runInAction } from 'mobx';
const { store, form, loading, errors, entity } = this.props;
const { store, form, loading, errors, entity:contact } = this.props;
// joining arrays
const odd = [1, 3, 5 ];
const nums = [2 ,4 , 6, ...odd];
console.log(nums); // [ 2, 4, 6, 1, 3, 5 ]
// cloning arrays
const arr = [1, 2, 3, 4];
const arr2 = [...arr];
const odd = [1, 3, 5 ];
const nums = [2, ...odd, 4 , 6];
const { a, b, ...z } = { a: 1, b: 2, c: 3, d: 4 };
console.log(a) // 1
console.log(b) // 2
console.log(z) // { c: 3, d: 4 }
mandatory = () => {
throw new Error('Missing parameter!');
}
foo = (bar = mandatory()) => {
return bar;
}
~~4.9 // 4
2**3 // 8
2**4 // 4
4**3 // 64
if(~arr.indexOf(item)) { // Confirm item IS found
}
if(!~arr.indexOf(item)) { // Confirm item IS NOT found
}
const credits = { producer: 'John', director: 'Jane', assistant: 'Peter' };
const arr = Object.entries(credits);
console.log(arr);
/** Output:
[ [ 'producer', 'John' ],
[ 'director', 'Jane' ],
[ 'assistant', 'Peter' ]
]
**/
const credits = { producer: 'John', director: 'Jane', assistant: 'Peter' };
const arr = Object.values(credits);
console.log(arr);
/** Output:
[ 'John', 'Jane', 'Peter' ]
**/
function App(props){
const test = () => ("test")
return(
<p>App {test()}</p>
)
}
alert(typeof null); // alerts 'object'
alert(null instanceof Object); // evaluates false
alert(typeof NaN); // alerts 'Number'
alert(NaN === NaN); // evaluated false
alert('10 13 21 48 52'.replace(/\d/g, function(match) {
return parseInt(match) < 3 ? '*' : match;
})); ** *3 ** 48 5*
(function() {
var undefined = 'foo';
alert(undefined, typeof undefined); // foo string
})();
alert(new Array() == false); // evaluates true
check compatibility on: vibrate()
window.navigator.vibrate(500); // Vibrates for 500 miliseconds
check compatibility on: navigator.connection, rtt, downlink, effectiveType
console.log(navigator.connection.rtt); // Latency
console.log(navigator.connection.effectiveType) // kind of connection the internet speed aproaches best
console.log(navigator.connection.downlink); // Doanload speed in megabits per second
input.addEventListener("paste", function(e){
e.preventDefault() // prevents default action
})