FACG6 / books-autocomplete

https://books-a.herokuapp.com/
0 stars 0 forks source link

ES6: use Destructuring #41

Open othman-shamla opened 5 years ago

othman-shamla commented 5 years ago

https://github.com/FACG6/books-autocomplete/blob/05b6575b147d1e64971601b3af76ce41af0dd6c2/public/js/dom.js#L24 https://github.com/FACG6/books-autocomplete/blob/05b6575b147d1e64971601b3af76ce41af0dd6c2/public/js/dom.js#L27 https://github.com/FACG6/books-autocomplete/blob/05b6575b147d1e64971601b3af76ce41af0dd6c2/public/js/dom.js#L29 u can write it like this

const { value: inputValue } = bookSearch;
if (inputValue.trim() == '') {
    alert('Enter some value');
} else if (inputValue != null) {
    fetchData('POST', inputValue, '/search', (response) => {
        if (response == '') {
            alert("no such value");
        }

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Assigning_to_new_variable_names

AymanAlqoqa commented 5 years ago

thanks for your opinion, I'll take care of it in next project (lack of time) thanks